[OpenLayers-Users] drawing a geojson layer

christopher.schmidt at nokia.com christopher.schmidt at nokia.com
Fri Sep 23 16:05:11 EDT 2011


Are you using OSM? Did you reproject your coordinates anywhere?

-- Chris

On Sep 23, 2011, at 3:07 PM, ext Puneet Kishor wrote:

> I have a fairly straightforward code like so, with the JSON data coming out of Pg. I am using OL 2.11
> 
>    var data = {
>      "type" : "FeatureCollection"
>      "features" : [
>         {
>            "geometry" : {
>               "coordinates" : [[[x1, y1], [x2, y2], [x3, y3]]],
>               "type" : "MultiLineString"
>            },
>            "type" : "Feature",
>            "properties" : {"code" : 101, "desc" : "blah" }
>         },
>         {
>            "geometry" : {
>               "coordinates" : [[[x1, y1], [x2, y2], [x3, y3]]],
>               "type" : "MultiLineString"
>            },
>            "type" : "Feature",
>            "properties" : {"code" : 102, "desc" : "blah" }
>         },
>         {
>            "geometry" : {
>               "coordinates" : [[[x1, y1], [x2, y2], [x3, y3]]],
>               "type" : "MultiLineString"
>            },
>            "type" : "Feature",
>            "properties" : {"code" : 103, "desc" : "blah" }
>         },
>      ]
>    }
> 
>    var geojson_format = new OpenLayers.Format.GeoJSON();
>    var lyr = new OpenLayers.Layer.Vector("layer name"); 
>    PK.vars.map.addLayer(lyr);
>    trenches.addFeatures(geojson_format.read(data));
> 
> Yet, no errors and no features drawn on the map. What am I doing wrong?
> 
> Puneet._______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users



More information about the Users mailing list