[OpenLayers-Users] drawing a geojson layer
Puneet Kishor
punk.kish at gmail.com
Fri Sep 23 15:07:43 EDT 2011
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.
More information about the Users
mailing list