[mapguide-users] Geting Selected Features
Matt Feeney
matthew.feeney at capita.co.uk
Thu Jun 11 05:29:50 EDT 2009
Trying to get the Features that have been selected from a Ajax Map Viewer.
The JavaScript is passing back the selection XML to the server side.
On the Page Postback, i read the Params that are returned, depending on the
correct parameter value i run the function below.
Private Sub ListSelected(ByVal sessionId As String, ByVal mapname As String,
ByVal selectionXML As String)
Dim userInfo As MgUserInformation = New MgUserInformation(sessionId)
Dim site As New MgSite()
site.Open(userInfo)
Dim siteConnection As New MgSiteConnection()
siteConnection.Open(userInfo)
Dim map As New MgMap()
Dim mapId As MgResourceIdentifier = New
MgResourceIdentifier("Session:" + sessionId + "//" + mapname + "." +
MgResourceType.Map)
Dim resourceService As MgResourceService =
siteConnection.CreateService(MgServiceType.ResourceService)
map.Open(resourceService, mapname)
Dim featureService As MgFeatureService =
siteConnection.CreateService(MgServiceType.FeatureService)
Dim sel As MgSelection = New MgSelection(map, selectionXML)
sel.Open(resourceService, mapname)
Dim lyrs As MgReadOnlyLayerCollection = sel.GetLayers()
For Each lyr As MgLayerBase In lyrs
If lyr.Selectable = True Then
Dim count As Integer = sel.GetSelectedFeaturesCount(lyr,
lyr.GetFeatureClassName())
sel.GetSelectedFeatures(lyr, lyr.GetClassName(), False)
End If
Next
End Sub
The line of text in bold throws an exception which makes no sense. (see
Below)
OSGeo.MapGuide.MgNullReferenceException was unhandled by user code
Message="Null reference."
Source="MapGuideDotNetApi"
StackTrace:
- MgMap.GetService line 93 file
d:\buildforgeprojects\mapguide_open_source_v2.0\build_27.16\mgdev\common\mapguidecommon\MapLayer/Map.cpp
Many Thanks in Advanace
Matt
--
View this message in context: http://n2.nabble.com/Geting-Selected-Features-tp3061076p3061076.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list