[OpenLayers-Users] dynamic WMS add/remove problem

Balázs Bámer bamerbalazs at gmail.com
Mon Jun 15 11:25:57 EDT 2009


Hi All,

I try to create a page where the user can upload a shapefile (dbf shp
shx in a zip file) and its contents are added to the existing display
of WMSes. This works fine. However, my goal is to allow only one
uploaded shapefile to be displayed, so when the user uploads a new
one, the old should be removed and the new one is displayed instead.
The old one reappears. This happens even if a wrong file is uploaded
between the two good ones: first the old one is removed, error message
appears (fine), but the new good shapefile just brings back the old
one. After page reload if I start with the new one, it is displayed
but the behaviour is similar. The phenomenon is the same under
Openlayers 2.7 and 2.8 rc5.

Here is the application:
http://att-it.homelinux.net:22080/blokknez/
file must be selected in the file box "Fajl".

Here are two shapefiles to experiment with:
http://att-it.homelinux.net:22080/blokknez/meres.zip
http://att-it.homelinux.net:22080/blokknez/meres2.zip

The code is here:
http://att-it.homelinux.net:22080/blokknez/index.php.txt

The code used to add WMS:
var shapefile_wms = new OpenLayers.Layer.WMS("shapefile [name from PHP var]",
"http://att-it.homelinux.net:22080/cgi-bin/ms-5.4.1/mapserv",
{
    layers: 'shapefile',
    map: '/var/lib/mapserver-5.4.1/blokknez/shapefile/shapefile.map',
    transparent: "true"
},
{
    scales:[2000000,1500000,1000000,750000,500000,300000,200000,150000,100000,75000,50000,30000,20000,15000,10000,7500,5000,3000,2000,1500,1000],
    isBaseLayer:false,
    visibility:true
});
window.parent.map.addLayer(shapefile_wms);
shapefile_wms.id="shapefile";

The code used for WMS removal (try needed because OpenLayers 2.7 threw
some exception):
layer=window.parent.map.getLayer("shapefile");
if(layer!==null) {
        window.parent.map.removeLayer(layer);
        try {
                layer.destroy();
        }catch(dfdf) {}
}

The exception without try in Firebug is
OpenLayers is not defined
getURL()()OpenLayers.js (sor 1382)
blokknez()()blokknez (sor 9)
[Break on this error]
if(this.params.FORMAT=="image/jpeg"){thi...ame,this.url,this.params,this.options);}

What can be the problem?

Thank you in advance.
Best regards: Balázs



More information about the Users mailing list