I have been trying to load a GeoJSON without success. I have a map with a background layer from OSM. I have some data in 4326 I want to overlay on that map. I do not want to transform coordinates one by one on the server-side and I'd rather have OpenLayers transform them on the fly ... if possible at all.

I have tried using the "projection" attribute under the vector Layer, vector Source, main background layer, ... everywhere I have thought of ... to no avail: the sample point keeps showing near 0,0.

I set up a fiddle with my test code, any idea? Is it simply not possible?


The data here is just a sample. Once I get it to work I'll load the data with AJaX (Asyncronous Javascript XML).

1 Answer 1


I have put a projection setting in your source definition and it seems to work:

var vS=new ol.source.GeoJSON(
        "object": data,
         projection: 'EPSG:3857'

This is the result: http://jsfiddle.net/zzahmbff/3/

Perhaps this resource can help you to see different ways to load vector data: http://acanimal.github.io/thebookofopenlayers3/chapter03_03_vector_source.html

  • Sweet, thank you gcarrillo! I thought I had to specify the EPSG of the data, rather than the EPSG of visualization. I was wrong and didn't even think of this, thanks again. Commented Feb 17, 2015 at 15:15
  • In my opinion, it's not your fault. The projection parameter is a bit misleading, I wonder why they didn't just name it destProjection, targetProjection, or sth like that. Commented Feb 17, 2015 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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