[mapguide-users] Geting Selected Features
Kenneth Skovhede, GEOGRAF A/S
ks at geograf.dk
Fri Jun 12 09:18:33 EDT 2009
Instead of:
Dim map as New MgMap()
try
Dim map as New MgMap(resourceService)
Regards, Kenneth Skovhede, GEOGRAF A/S
Matt Feeney skrev:
> 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
>
>
>
>
>
More information about the mapguide-users
mailing list