[OpenLayers-Users] trying to add vector data from featureserver
alim karim
alim.karim at gmail.com
Wed Jan 9 13:00:06 EST 2008
i am trying to add a vector layer into an openlayers map. the vector
data originates from a shapefile and is served up by featureserver.
the code below is what i have so far. using this, nothing appears
within the map. no errors are reported either. querying the
featureserver directly gives me the data i need, so the problem is at
the openlayers end.
var ol_map = new OpenLayers.Map("map", {projection: 'EPSG:4326',
maxResolution:"auto"});
var vec = new OpenLayers.Layer.GML("FS",
"http://192.168.0.105/featureserver/featureserver.cgi/ogr_test_latlong?format=gml",
{format: OpenLayers.Format.APP, isBaseLayer: true});
ol_map.addLayer(vec);
var max_extent = new OpenLayers.Bounds(1167908.917283, 786004.626689,
1178260.558180, 791188.04900);
ol_map.setOptions({maxExtent: max_extent, center: new
OpenLayers.LonLat(-123.46675, 52.088474)});
ol_map.zoomToMaxExtent();
i have tried retrieving the data as geojson (which would be ideal) and
creating a vector layer from that using:
var ol_layer = new OpenLayers.Layer.Vector("some name", {isBaseLayer: false});
new Ajax.Request(
http://192.168.0.105/featureserver/featureserver.cgi/ogr_test_latlong
{
method:'get',
requestHeaders: {Accept: 'application/json'},
onSuccess: function(transport){
var geojson = new OpenLayers.Format.GeoJSON();
feature_coll = geojson.read(transport.responseText,
"FeatureCollection");
ol_layer.addFeatures(feature_coll);
},
onComplete: function (){},
onFailure: function (transport) { alert ("an error occurred."); }
});
}
in both cases, i can see that the data is indeed returned (through
firebug), but i do not see anything appearing on the map.
any help would be appreciated.
thanks in advance
More information about the Users
mailing list