I don't have a great level in javascript and OpenLayers, and i am trying to realize a map with static markers pointing airports in all the world.
Well i tried to search my answer but i can't resolve my problem.
I already tried to find docs or examples, but every time it doesn't work.
Please if anybody can help me by telling me how to create markers based on a list of data?
Thank you a lot.
(fiddle)
var vectorLayer = new ol.layer.Vector({
source: new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: 'url_of_your_file'
})
});
map.addLayer(vectorLayer);
This way you can load a GeoJSON file into your map.
If you want, say, a circle marker you add a style to ol.layer.Vector
like:
var vectorLayer = new ol.layer.Vector({
source: new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: 'url_of_your_file'
}),
style: new ol.style.Style({
image: new ol.style.Circle({
radius: 10,
fill: new ol.style.Fill({
color: '#ffff00'
})
})
})
});