[mapguide-users] SetSelectionXML Issue

Carrillo, John JBCarrillo at rcflood.org
Wed Feb 16 18:43:04 EST 2011


               I'm having a couple issue with the code below and I'm
guessing that they are related. I have a map that I created and when I
pull it up initially, I can use the Select Tool and see the Tool Tips on
the layer I'm having issues with, "J_Parcels". But when I run the query
below, the  "SetSelectionXML" doesn't work and I can no longer use the
Select Tool or the Tool Tips in my map. To ZoomToView is working
properly but the Parcel that is queried is not highlighted. I know I'm
getting data returned. Not sure why after the query I can't use the
tools or why the SetSelectionXML isn't working. Also, when I try and Pan
or Zoom after the query, the map goes away, just a blank screen. Any
help would be greatly appreciated. 

 

Thanks, JC

 

 

<%

  

    'from the previous page

    Dim sessionId As [String] = Request.Form.[Get]("SESSION")

    Dim encroachPermit As [String] = Request.Form.[Get]("iAPN")

    Dim webLayout As [String] = "Library://JC_Test/WebLayer/J.WebLayout"

 

    'path to web config

    Dim realPath As String =
Request.ServerVariables("APPL_PHYSICAL_PATH")

    Dim configPath As [String] = realPath & "webconfig.ini"

    MapGuideApi.MgInitializeWebTier("C:\Program
Files\AutoDesk\MapGuideEnterprise2011\WebServerExtensions\www\webconfig.
ini")

    

 

    Dim userInfo As New MgUserInformation(sessionId)

    Dim siteConnection As New MgSiteConnection()

    siteConnection.Open(userInfo)

 

    Dim resService As MgResourceService =
DirectCast(siteConnection.CreateService(MgServiceType.ResourceService),
MgResourceService)

    Dim featureService As MgFeatureService =
DirectCast(siteConnection.CreateService(MgServiceType.FeatureService),
MgFeatureService)

 

    'Map from Map Guide

    Dim map As New MgMap()

    map.Open(resService, "J")

 

 

    'Query for the second condition

    Dim nameQuery As New MgFeatureQueryOptions()

    nameQuery.SetFilter("APN = '" & encroachPermit & "'")

 

    'second feature sources to compare first to

    Dim encroachId As New MgResourceIdentifier("Library://Oracle Feature
Source/FCT1TEST_Assessor feature source.FeatureSource")

    Dim featureReader As MgFeatureReader =
featureService.SelectFeatures(encroachId, "PARCELPTS", nameQuery)

 

    

    Dim list As New ArrayList()

    Dim x_coordinate As New ArrayList()

    Dim y_coordinate As New ArrayList()

    Dim lldd As Double

    Dim urdd As Double

    

    

    While featureReader.ReadNext()

        list.Add(featureReader.GetString("APN"))

        

        

        'GET X Y  FROM GEOMETRY

        Dim geometryBytes As MgByteReader =
featureReader.GetGeometry("GEOMETRY")

        Dim agfReader As New MgAgfReaderWriter()

        Dim districtGeometry As MgGeometry =
agfReader.Read(geometryBytes)

        Dim env As MgEnvelope = districtGeometry.Envelope()

               

        lldd = env.GetLowerLeftCoordinate().GetX

        urdd = env.GetLowerLeftCoordinate().GetY

        

        

    End While

    Response.Write(list(0) & "<BR />")

    

    'Highlight the query result on the map

    Dim selection As New MgSelection(map)

    Dim layer As MgLayer = map.GetLayers().GetItem("J_Parcels")

    

    

    

        

    featureReader = featureService.SelectFeatures(encroachId,
"PARCELPTS", nameQuery)

    selection.AddFeatures(layer, featureReader, 0)

    Dim selectionXML As [String] = selection.ToXml()

   

   

     

    

    

    

    

  

%>

<%--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

 

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>H</title>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
/>

    <meta http-equiv="content-script-type" content="text/javascript" />

    <meta http-equiv="content-style-type" content="text/css" />

   

 

    <script type="text/javascript">

        function onPageLoad() {

 

 

 

 

 

            var selectionXML2 = '<%= selectionXML %>';

            alert(selectionXML2);

 

            var t = setTimeout("alertMsg()", 9000);

            var t2 = setTimeout("alertMsg2()", 4000);

 

 

        }

 

        function alertMsg() {

 

            alert('45');

            parent.parent.ViewerFrame.mapFrame.ZoomToView('<%= lldd %>',
'<%= urdd %>', 5000, true);

 

        }

 

        function alertMsg2() {

 

            alert('45');

            var selectionXML2 = '<%= selectionXML %>';

            alert(selectionXML2);

 

 
parent.parent.ViewerFrame.mapFrame.SetSelectionXML(selectionXML2);

 

           

 

        }

 

 

 

   

    </script>

 

</head>

<body id="body1" class="AppFrame" onload="onPageLoad()">

    <strong>The following are the query results: </strong>

    <ul>

        <%

            For i As Integer = 0 To list.Count - 1

                Dim address As [String] = list(i).ToString()

                If address <> "" Then

                    Response.Write("<li>" & list(i).ToString() & "</li>"
& vbLf)

                End If

            Next

 

        %>

    </ul>

 

    <iframe id="imap"
src="/mapguide2011/mapviewernet/ajaxviewer.aspx?SESSION=<%=

sessionId %>&WEBLAYOUT=<%= webLayout %>" name="ViewerFrame" height="700"


        width="1200" scrolling="yes" />

 

</body>

</html>

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20110216/c9e42492/attachment.html


More information about the mapguide-users mailing list