[mapguide-users] make query on the fly

Berdel, Brian brian.berdel at mcmtrans.com
Wed Jun 4 09:55:46 EDT 2008


I think you referring to selectwithin there is a command in the
interface to do this as well as some examples such as selectwithin.php
or selectwithin.aspx  here is vb code that will accomplish it after your
initial selection has been made. 

		Dim layers as string = "YourLayerName"
            InitializeWebTier()
            Dim cred As New MgUserInformation(sessionId)
            'connect to the site and get an instance of each service
used in this script 
            ' 
            Dim site As New MgSiteConnection()
            site.Open(cred)
            Dim featureSrvc As MgFeatureService =
TryCast(site.CreateService(MgServiceType.FeatureService),
MgFeatureService)
            Dim renderingSrvc As MgRenderingService =
TryCast(site.CreateService(MgServiceType.RenderingService),
MgRenderingService)
            Dim resourceSrvc As MgResourceService =
TryCast(site.CreateService(MgServiceType.ResourceService),
MgResourceService)
            'load the map runtime state 
            ' 
            Dim map As New MgMap()
            map.Open(resourceSrvc, Session("MapName"))
		'this is needed if you want to select multiple layers,
but works  		'with one as well...
            Dim layersList As String() = layers.Split(","c)
            If layersList.Length > 0 Then
                Dim layerNames As New MgStringCollection()
                For i As Integer = 0 To layersList.Length - 1
                    layerNames.Add(layersList(i))
                Next
                ' create a multi-polygon or a multi-geometry containing
the input selected features 
                ' 
                Dim inputGeom As MgGeometry =
MultiGeometryFromSelection(featureSrvc, map, selectionXML)
                If inputGeom IsNot Nothing Then
                    ' Query all the features belonging the the layer
list that intersects with the input geometries 
                    ' 
                    Dim fi As MgFeatureInformation =
renderingSrvc.QueryFeatures(map, layerNames, inputGeom,
MgFeatureSpatialOperations.Intersects, -1)
                    If fi IsNot Nothing Then
                        Dim resultSel As MgSelection = fi.GetSelection()
                        If resultSel IsNot Nothing Then
                            ' Return XML 
                            selectionXML = resultSel.ToXml
                        End If
                    End If
                End If
            End If

Brian  Berdel 
McMahon Associates, Inc. 
p: 215.283.9444
www.mcmtrans.com 

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of
erictsn at cadbeyond.com
Sent: Wednesday, June 04, 2008 4:37 AM
To: mapguide users
Subject: [mapguide-users] make query on the fly


Hi All

In the application there is two core layers; layer A is initially
displayed
in the map and can be selected. How I can make a query which uses the
selected feature of layer A? and then the Layer B will be highlight
those
feature automatically & on the fly. Can I do that? The $SelectionString
shows the selected feature ID. It can be used to query the feature of
Layer
B. 


Regards,
Eric 

_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users


More information about the mapguide-users mailing list