[OpenLayers-Users] delete layers
eider at fh-bingen.de
eider at fh-bingen.de
Fri Apr 3 14:38:20 EDT 2009
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)" <lortiz at compegps.com>:
> 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
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
More information about the Users
mailing list