If this is a true reproduction of your code, then you can't pass a
string to the Remove method, it needs to be a MapLayer object. You can
pass a string (or MapLayer object) to the remove method.

Keith

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Alex
Fordyce
Sent: 05 September 2007 23:06
To: [email protected]
Subject: [mapguide-users] Remove layer C#


I'm to see if a layer exists and remove it if it exists. The layer would
have been saved as a temporary resource. Here is the code.  

// get the map
MgMap map = new MgMap(siteConnection);
map.Open(mgMapName);
        
MgLayerCollection layerCol = map.GetLayers();
        
if(layerCol.Contains("myLayer"))
{
     layerCol.Remove("myLayer");
}
        
.... Add myLayer code here .....

I get the following error whether or not the layer exists:

 Compiler Error Message: CS1502: The best overloaded method match for
'OSGeo.MapGuide.MgLayerCollection.Remove(OSGeo.MapGuide.MgLayerBase)'
has some invalid arguments

Source Error:

Line 42:        if(layerCol.Contains("myLayer"))
Line 43:        {
Line 44:                layerCol.Remove("myLayer");
Line 45:        }
Line 46:        

Anyone have any suggestions?

Thanks in advance.

alex
--
View this message in context:
http://www.nabble.com/Remove-layer-C--tf4388428s16610.html#a12511956
Sent from the MapGuide Users mailing list archive at Nabble.com.

_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users


This message has been scanned for viruses by MailControl - (see
http://bluepages.wsatkins.co.uk/?6875772)


This email and any attached files are confidential and copyright protected. If 
you are not the addressee, any dissemination of this communication is strictly 
prohibited. Unless otherwise expressly agreed in writing, nothing stated in 
this communication shall be legally binding.

The ultimate parent company of the Atkins Group is WS Atkins plc.  Registered 
in England No. 1885586.  Registered Office Woodcote Grove, Ashley Road, Epsom, 
Surrey KT18 5BW.

Consider the environment. Please don't print this e-mail unless you really need 
to. 
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users

Reply via email to