In the following code if I use the WMS layer my polygons (the geos variable) are displayed properly. If I switch to the OSM layer the OSM layer displays just fine, but the vector layer disappears from the map (despite being in the layers collection. Any ideas?
var options = {
projection: "EPSG:4326",
displayProjection: "EPSG:4326",
numZoomLevels: 20
};
that.map = new OpenLayers.Map('map', options);
// that.layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
// "http://vmap0.tiles.osgeo.org/wms/vmap0",
// { layers: 'basic' });
that.layer = new OpenLayers.Layer.OSM({ opacity: 50 });
var featurecollection = {
"type": "FeatureCollection",
"features": [
{ "geometry": {
"type": "GeometryCollection",
"geometries": geos
},
"type": "Feature",
"properties": {}
}
]
};
var geojson_format = new OpenLayers.Format.GeoJSON();
var vector_layer = new OpenLayers.Layer.Vector();
that.map.addLayers([vector_layer, that.layer]);
vector_layer.events.register("featureadded", that.map.layers[1], that.zoomToLeftHalf);
vector_layer.addFeatures(geojson_format.read(featurecollection));
asked
01 Mar '12, 04:09
coreyperkins
1●1●1●1
accept rate:
0%