What i want to do here is to create a vector layer (using openlayers) from a GeoServer JSON Response. Actually i'm doing this:

var url = "http://"+ip+":"+puerto+"/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=tiger:poi&outputFormat=text/javascript&format_options=callback:getJson";

                    jsonp: false,
                    jsonpCallback: 'getJson',
                    type: 'GET',
                    url: url,
                    async: false,
                    dataType: 'jsonp',
                    success: function(jsonObject) {

With the code above (after a long time of headaches with cross domain issues) we can retrieve data from GeoServer (through WFS) using JSONP.

The function below handles the response, tries to create the vector layer and put that vector over the map, using GeoJSON.

function create_GeoJSON(json){

    var in_options = {
            'internalProjection': window.map.projection,
            'externalProjection': window.map.projection

    var jsonString = JSON.stringify(json);

    var geojson_format = new OpenLayers.Format.GeoJSON(in_options);
    var vector_layer = new OpenLayers.Layer.Vector("Consulados");
    vector_layer.addFeatures(geojson_format.read(jsonString, "FeatureCollection"));
    window.map.addLayer(vector_layer); }

Now, the problem is that the map isn't showing the layer components properly. As you can see i only see a point (or maybe a lot of superposed) drawed over the (0,0). This seems to be an issue related with the coordinates, projections or something like that.

By the way, here is the map init:

var options = {
   projection: "EPSG:900913",
   displayProjection: "EPSG:4326",
   controls: [],

window.map = new OpenLayers.Map('map_canvas', options);

What you think about that? I "waste" a lot of time over this right now and still don't have a solution.


PS: Feel free to edit the post, my english is a little poor.

How the map looks like

1 Answer 1


Yes, this is definitely a projection problem.
First of all, use EPSG:3857 instead of EPSG:900913 (they are the same thing, but 3857 is the official one - however this is not causing the problem) In GeoServer, what is your layers projecton? Try the EPSG:3857 as declared, and choose reproject form native to declared.
And then in your code, in options omit the displayProjection: "EPSG:4326", line
I hope this helps

  • The layers that we will use in the project has EPSG:4326 as declared, for this reason we think that make sense to add the display projection explicitly in the map init options. What kind of problems can carry change that to EPSG:3857 and force the reproyection in our layers?
    – halbano
    Commented Feb 27, 2014 at 18:46
  • I think none, but I am not sure..
    – ylka
    Commented Feb 28, 2014 at 7:12

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.