[Mapserver-users] getLayerByName phpMapscript

Inna Janssen innaj@web.de
Wed, 24 Mar 2004 15:26:34 +0100


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@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@lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users




_______________________________________________
Mapserver-users mailing list
Mapserver-users@lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users