I already tried to put the following function and new Vector Layer into my code. I uploaded the GeoJSON File into my BPlaced account to link the file in my code, is that right?
The Geojson has the same Coordinate System as the website. Also the code seems to work but I don't see any of the Geojson.
Or is there another way to embed GeoJSON into OpenLayers?
Here is my code:
var vectorLayerJSON = new ol.layer.Vector({
source: new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: 'http://kristinab.bplaced.net/ALDI_LIDL_Buffer_KBS_3857.geojson'
}),
style: new ol.style.Style({
image: new ol.style.Circle(({
radius: 20,
fill: new ol.style.Fill({
color: '#ffff00'
})
}))
})
});
Best Answer
welcome to the SO :)
I believe that there are several ways to add vectors (geojson) data to map
1) loading vectors using geojson file url:
2) generating vector layer from geojson object
More detailed example on OpenLayer 3 example page Geojson Example
3) reading vector features from ajax
Hope it helps :)