[mapguide-users] clear selection of one layer
stoff
mail at effing.org
Sat Jan 17 07:19:20 EST 2009
I tried to manage the selection on serverside (look below) and afterwards
refreshing the map
by parent.parent.mapFrame.Refresh(); from the taskframe clientside.
Refreshing works, but the
layers I want the selection cleared are still shown
Here is my serverside asp.net(vb.net) code:
Protected Sub ManageSelection(ByVal selectionXML As String, ByVal siteConn
As MgSiteConnection, ByVal mapName As String)
Dim resourceService As MgResourceService =
TryCast(siteConn.CreateService(MgServiceType.ResourceService),
MgResourceService)
Dim featureService As MgFeatureService =
TryCast(siteConn.CreateService(MgServiceType.FeatureService),
MgFeatureService)
Dim i As Integer
Dim map As New MgMap()
Dim layers As MgReadOnlyLayerCollection
Dim selection As MgSelection = Nothing
map.Open(resourceService, mapName)
If (selectionXML IsNot Nothing) AndAlso (selectionXML <> "") Then
selection = New MgSelection(map, selectionXML)
layers = selection.GetLayers()
Else
layers = Nothing
End If
If layers IsNot Nothing Then
Dim queryOptions As New MgFeatureQueryOptions()
For i = 0 To layers.GetCount() - 1
Dim layer As MgLayer = TryCast(layers.GetItem(i), MgLayer)
If (layer IsNot Nothing) And layer.Name =
m_ExpertiseConfig.SelectableLayer Then
' Create a filter containing the IDs of the selected
features on this layer
Dim layerClassName As String =
layer.GetFeatureClassName()
Dim selectionString As String =
selection.GenerateFilter(layer, layerClassName)
' Get the feature resource for the selected layer
Dim layerFeatureId As String =
layer.GetFeatureSourceId()
Dim layerFeatureResource As New
MgResourceIdentifier(layerFeatureId)
' Apply the filter to the feature resource for the
selected layer. This returns
' an MgFeatureReader of all the selected features.
queryOptions.SetFilter(selectionString)
Dim featureReader As MgFeatureReader =
featureService.SelectFeatures(layerFeatureResource, layerClassName,
queryOptions)
' get FIDs of all objects
m_slSelectionFIDs.Clear()
While featureReader.ReadNext()
If selectionString.Contains("FID") Then
Debug.Print(featureReader.GetInt64("FID"))
'Do something else ...
End If
End While
Else
'Here is my problem: How do I clear the selection of the
layer?
If selection.GetLayers.Contains(layer) Then
selection.GetLayers.Remove(layer)
Dim layerFeatureId As String =
layer.GetFeatureSourceId()
Dim layerFeatureResource As New
MgResourceIdentifier(layerFeatureId)
selection.Save(resourceService, m_giUtils.MapName)
layer.ForceRefresh()
End If
End If
Next
Else
Debug.Print("No Selection")
End If
map.Save()
End Sub
--
View this message in context: http://n2.nabble.com/clear-selection-of-one-layer-tp2171557p2172842.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list