0

I've used ol.interactin.Draw to draw and save features in GeoJSON format. But the drawn features are stored in EPGS:3857 and my preference is WGS 84. For that, I've used this snippet code to apply dataProjection and featureProjection properties but nothing has been changed.

draw = new ol.interaction.Draw({
        source: vectorSource,
        type: selectedType.value
    });

    draw.on('drawend', function (evt) {

        var extraFeature = evt.feature; 
        var features = vectorSource.getFeatures();
        var allFeatures = features.concat(extraFeature);

        featuresGeoJSON = parser.writeFeatures(allFeatures, {
            dataProjection: 'EPSG:3857',
            featureProjection: 'EPSG:4326'
        });
});
1

You have a typo, it is EPSG (not EPGS)

  • It was a mistake but the problem was not related to that. I switched dataProjection with featureProjection and it worked fine. – nasser tahani Mar 4 '18 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.