Infrastructure Map Server Forum
Welcome to Autodesk’s Infrastructure Map Server Forums. Share your knowledge, ask questions, and explore popular Infrastructure Map Server topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Displaying a selection set

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
soudemans
2533 Views, 4 Replies

Displaying a selection set

Hi,

 

I am working on the classic "how to isolate a particular layer from a bunch of selected features and then highlight them" using VB. I have gotten as far as isolating the features, but I have not been able to find a way to update the map showing the selected features.  I have had to piece this function together from code samples in C# and Javascript.  The final piece is the 

"Parent.Parent.mapFrame.SetSelectionXML(_SelectionXml)" at the bottom for which I cannot find a VB equivalent

 

Any help would be much appreciated?  Code below:

 

Protected Sub Page_Load(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Me.Load
    Dim featureReader As MgFeatureReader
    ' Initialize MapGuide
    InitMapGuide()

    Dim map As New MgMap(_SiteConnection)
    map.Open(_ResourceService, _MapName)
    Dim selection As New MgSelection(map, _SelectionXml)

    Dim subFilterSize As Int16 = 20
    Dim SelectionString As String
    Dim layer As MgLayer = map.GetLayers().GetItem("Hydrants")
    Dim QueryOptions As MgFeatureQueryOptions = _ 
        New MgFeatureQueryOptions()

    SelectionString = selection.GenerateFilter _
        (layer, layer.FeatureClassName)
    QueryOptions.SetFilter(SelectionString)
    featureReader = selection.GetSelectedFeatures _
        (layer, layer.FeatureClassName, False)
    selection = New MgSelection(map)
    selection.AddFeatures(layer, featureReader, 0)
    _SelectionXml = selection.ToXml

    'This is the JavaScrip for which I cannot find
    '   a VB equivalent: 
    'Parent.Parent.mapFrame.SetSelectionXML(_SelectionXml)
End Sub

 

4 REPLIES 4
Message 2 of 5
jackie.ng
in reply to: soudemans

parent.parent.mapFrame.SetSelectionXML is javascript call that executes client-side (in your web browser).

 

Your VB.net code executes on the (web) server-side.

 

Your VB.net code should not be calling this method (which doesn't exist), but rather it should be writing the javascript call to this method.

 

- Jackie

Message 3 of 5
soudemans
in reply to: soudemans

Thanks for your suggestion Jackie,

 

But being that I am rather new at this and since I did spent the better part of today trying to figure out how to implement your suggestion (without much success) would it be possible for you to include a bit of code to show how this is done, preferably some code that relates to the "mapguide" problem at hand?  Thanks,

 

Sierk

Message 4 of 5
scott
in reply to: soudemans

Hi Sierk,

 

Here's a handy function that sends the appropriate JavaScript to the client to select features on the map based on an MgSelection object. You should be able to call this from your code just after you use selection.AddFeatures.

 

- Scott

 

 

''' <summary>
''' Highlights the selected features on the map.
''' </summary>
''' <param name="selection">The MgSelectionBase object.</param>
Public Sub HighlightFeatures(selectionSet As MgSelectionBase)
	' Escape any single quotes 
	Dim xml As String = selectionSet.ToXml().Replace("'", "\'")

	' Build the JavaScript code to set the active selection
	Dim s As String = "<script language=""javascript"">" & vbLf
	s += "window.onload = function()" & vbLf
	s += "{" & vbLf
	s += "  var main = parent.parent;" & vbLf
	s += "  var map = main.GetMapFrame();" & vbLf
	s += "  map.SetSelectionXML('" & xml & "');" & vbLf
	s += "}" & vbLf
	s += "</script>" & vbLf

	' Use the HttpResponse object to send this code to the client
	Response.Write(s)
End Sub

 

 

 

Message 5 of 5
soudemans
in reply to: soudemans

Thanks Scott, that worked like a charm.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report