[mapguide-users] Changing existing dynamic layer's Filter on
the fly
Maksim Sestic
max at geoinova.com
Thu Nov 15 10:51:42 EST 2007
This layer removal thingy is funny. Could anyone, plese, explain what's going
on here?
=== This works:
Dim layerName as String = "TestLayer"
Dim map As MgMap = ...get active MgMap from session...
Dim layerCol As MgLayerCollection = map.GetLayers()
Dim layerToRemove As MgLayer = Nothing
For Each layerItem As MgLayer In layerCol
If layerItem.Name = layerName Then
layerToRemove = layerItem
Exit For
End If
Next
If layerToRemove IsNot Nothing Then
layerCol.Remove(layerToRemove)
End If
=== But this won't work:
Dim layerName as String = "TestLayer"
Dim map As MgMap = ...get active MgMap from session...
Dim layer As MgLayer = map.GetLayers.GetItem(layerName)
Dim layerCol As MgLayerCollection = map.GetLayers()
Dim layerToRemove As MgLayer = Nothing
For Each layerItem As MgLayer In layerCol
If layerItem.Name = layerName Then
layerToRemove = layerItem
Exit For
End If
Next
If layerToRemove IsNot Nothing Then
layerCol.Remove(layerToRemove)
End If
I don't get it, it throws "The specified object was not found" exception.
Regards,
Maksim Sestic
--
View this message in context: http://www.nabble.com/Changing-existing-dynamic-layer%27s-Filter-on-the-fly-tf4811727s16610.html#a13773526
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list