[Mapserver-users] getLayerByName phpMapscript

Inna Janssen innaj at web.de
Wed Mar 24 09:26:34 EST 2004


Just get all Layers by index and compare if it has the name of the layer you want to add:

$found=false
for($i=0;$i<$map->numlayers;$i++) {
 $layer = $map->getLayer($i);
 if  ($layer->name == $YourSearchedLayerName) { $found=true;break}
}
if (!$found) add the layer
else don't add it 


Inna

Stéphane_RIFF <stephane.riff at cerene.fr> schrieb am 24.03.04 12:52:47:
> 
> I'd like to add dynamically a layer to my map only and only if that 
> layer doesn't already exist.
> 
> The problem is : getLayerByName returns a layerObject if the layer exist 
> but if it doesn't exist the function
> terminate the script and print the error. So i try with '@' to stop 
> error message but the script still die on getLayerByName.
> 
> So i'd like to know how i can be sure that a layer exist or not ???
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users







More information about the mapserver-users mailing list