[mapguide-users] Selection and Zoom Problem
Andy Morsell
amorsell at spatialgis.com
Wed Nov 8 11:31:50 EST 2006
Try saving the selection object to the server after you build it. Something
like:
Selection.Save(resourceService, mapname)
Andy Morsell, P.E.
Spatial Integrators, Inc.
http://www.SpatialGIS.com
_____
From: Markus Roth [mailto:m.roth at gds-team.de]
Sent: Wednesday, November 08, 2006 5:55 AM
To: users at mapguide.osgeo.org
Subject: [mapguide-users] Selection and Zoom Problem
Hello,
I have a problem with selections. In my .aspx (VB) site I generate the
selection string for the javascript. This works fine, but the feature is not
highlighted and no properties are shown in the Properties frame!?! But in
the statusbar the Info is shown that 1 feature is selected. I only use one
layer that is based on sdf file.
When I push the Button "Zoom to selection" after one feature is selected,
the map always zooms to coordinates X: 0.0 ; Y: 0.0!
Has anyone an idea what is wrong?
This is a sample of a generated selection string:
<?xml version="1.0" encoding="UTF-8"?><FeatureSet
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="FeatureSet-1.0.0.xsd"> <Layer
id="e82e9c52-ffff-ffff-8000-000cf1ae97f8"> <Class
id="SDF_2_Schema:sp_Lieg_flurstueck_F"> <ID>MTc2MQA=</ID> </Class>
</Layer></FeatureSet>
Here is my code:
Code from aspx.vb site:
Private Function SelectionOb(ByVal Filter As String, ByVal LayerName As
String)
Try
MapGuideApi.MgInitializeWebTier(". Path to webconfig.ini")
'##
Dim userInfo As New MgUserInformation(sessionID)
'##
Dim siteConnection As New MgSiteConnection()
siteConnection.Open(userInfo)
'##
Dim resourceService As MgResourceService =
siteConnection.CreateService(MgServiceType.ResourceService)
Dim featureService As MgFeatureService =
siteConnection.CreateService(MgServiceType.FeatureService)
Dim renderingService As MgRenderingService =
siteConnection.CreateService(MgServiceType.RenderingService)
'##
Dim MapDefID As New MgResourceIdentifier(mapDefinition)
Dim Map As New MgMap()
Dim mapname As String
mapname = MapDefID.GetName()
Map.Open(resourceService, mapname)
'##
Dim layers As MgLayerCollection = Map.GetLayers()
Dim layer As MgLayer
Dim layername1 As String = ""
Dim i As Integer = 0
Do Until layername1 = LayerName
layer = layers.GetItem(i)
layername1 = layer.GetName()
i += 1
Loop
'##
Dim query As New MgFeatureQueryOptions()
query.SetFilter(Filter)
Dim featureClassName As String = layer.GetFeatureClassName()
Dim featureSource As MgResourceIdentifier = New
MgResourceIdentifier(layer.GetFeatureSourceId())
Dim features As MgFeatureReader =
featureService.SelectFeatures(featureSource, featureClassName, query)
Dim hasResult As Boolean = features.ReadNext()
Dim Selection As MgSelection = New MgSelection(Map)
Select Case features.GetPropertyType("Key")
Case MgPropertyType.Int32
Selection.AddFeatureIdInt32(layer, featureClassName,
features.GetInt32("Key"))
Case MgPropertyType.String
Selection.AddFeatureIdString(layer, featureClassName,
features.GetString("Key"))
End Select
selectiontext = Selection.ToXml()
TextBox1.Text = selectiontext
layer.ForceRefresh()
Map.Save(resourceService)
features.Close()
query = Nothing
Catch ex As Exception
Label1.Text = ex.ToString
End Try
End Function
The javascript:
function Select(){
var seltext = '<%=selectiontext %>';
parent.parent.mapFrame.SetSelectionXML(seltext);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide_users/attachments/20061108/bec21819/attachment.html
More information about the Mapguide_users
mailing list