1

I have a confusion in creating vector layer. I have source data in GeoJSON and in EPSG:3857 (my map view is already in EPSG:3857).

Since it is in EPSG:3857, I thought it is not necessary to use any projection exp.

But vector is not displayed.

What I did:

 var vectorSourceCenter = new ol.source.Vector({
                features: features,
                //featureProjection: 'EPSG:3857'
                //projection: 'EPSG:3857'
   });

   var vectorCenterLayer = new ol.layer.Vector({
                source: vectorSourceCenter
   });

   map.addLayer(vectorCenterLayer );
1

Have you tried something like this in your code ?

source=new ol.source.Vector({
                    projection : 'EPSG:3857',
                    url: 'yourfile.geojson',
                format: new ol.format.GeoJSON()
                    });
layer=new ol.layer.Vector({
                source: source,
            })
    });

Then adding it to the map:

map.addLayer(layer);

I had a problem like this before but with 'EPSG:4326' and it turned out I was inversing the lat long in my layer source.

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.