map.removeLayer(gml_new,true); //THIS DOESN'T WORK cannot work as gml_new will always be null
gml_new is locally defined in the else-branch of this if-switch make gml_new global Quoting "Luis Ortiz (lortiz)" <[email protected]>: > Hi, > > I want to delete/destroy/remove a layer previously loaded in a zoom > event I'm trying this method, but it seems to don't work: > > var zoomed =false; > function mapEvent(event) { > var EPSG4326 = new OpenLayers.Projection("EPSG:4326"); > var EPSG900913 = new OpenLayers.Projection("EPSG:900913"); > var bounds = map.getExtent(); > bounds = bounds.transform(EPSG900913, EPSG4326); > > if (map.zoom==8) { > zoomed = true; > link = "http://localhost/getmap.php?bbox=" + bounds.toBBOX(); > if (zoomed) { > map.removeLayer(gml_new,true); //THIS DOESN'T WORK > zoomed = false; > } else { > var gml_new = new OpenLayers.Layer.GML("ZONE", link, > {format: OpenLayers.Format.GeoJSON, projection: map.displayProjection, > styleMap : aStyleMap }); > map.addLayer(gml_new); > } > } > } > > > _______________________________________________ > Users mailing list > [email protected] > http://openlayers.org/mailman/listinfo/users > _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
