I'm using Openlayers 3 and want to add a layer, in which the answer of the TurfJS function "merge" should be the source. Adding a GeoJSON-Layer directly in OpenLayers 3 is not problem and works fine. But when i load the GeoJSON-File in a variable an the use turf.merge(source), this can't be added in a layer anymore. I already tried to convert the answer of turf.merge in a FeatureCollection and add this as the layer source, but that's also not working
//define source (contains Polygons)
var source = new ol.source.Vector({
url: 'geb03_f_source.geojson',
format: new ol.format.GeoJSON({
})
});
//Merge source
var merged = turf.merge(source);
//define layer
var vectorLayer = new ol.layer.Vector({
source: merged,
projection: 'EPSG:3857'
});
//add layer to map
map.addLayer(vectorLayer);
The problem I see is that when loading the page, the GeoJSON-File is not loaded although it should.
But just loading and displaying the File works:
var source = new ol.source.Vector({
url: 'geb03_f_source.geojson',
format: new ol.format.GeoJSON({
})
});
var vectorLayer = new ol.layer.Vector({
source: source,
projection: 'EPSG:3857'
});
map.addLayer(vectorLayer);
Maybe something with the GeoJSON-Fomat is wrong when using turfs merge? I'm happy for every help!