Discussion:
defaultDataProjection in ol.format.GeoJSON does not work
(too old to reply)
Dietmar Stolz
2016-12-12 18:13:38 UTC
Permalink
Hi,

since API v3.18.0 it's not longer possible to transform feature
coordinates with defaultDataProjection and featureProjection:

source: new ol.source.Vector({
format: new
ol.format.GeoJSON({defaultDataProjection:'EPSG:3857',featureProjection:'EPSG:25832'}),
url: 'file.geojson'
})

I can only transform with readFeatures():

var e_bike = new ol.layer.Vector({
source: new ol.source.Vector()
});
$.ajax('file.geojson').then(function(response) {
var geojsonFormat = new ol.format.GeoJSON();
var features =
geojsonFormat.readFeatures(response,{dataProjection:'EPSG:25832',featureProjection:'EPSG:3857'});
e_bike.getSource().addFeatures(features);
});

Tested up to v3.20.0 API.

Thanks for your help!

Dietmar.

Continue reading on narkive:
Loading...