[mapguide-users] Selection Not Visible - No Features Selected

Mark Pendergraft markp at Meadgilman.com
Thu Jun 28 12:51:23 EDT 2007


I have followed the example in the developer's guide (1.2) "Use the Web
API to Set Selection". 

 

The code runs without any errors, but something is not right.  The
selection is not visible until I manually right-click the map and select
the option 'Refresh Map'.  Also, the status bar of the map says "0
features selected", and nothing shows up in the properties pane on the
left.

Even when I manually refresh the map, the parcel then shows up as being
selected but the properties window is blank, and the status bar still
says '0 features'

 

Thanks for the help.  My code follows:

 

-Mark Pendergraft

 

<%@ Page Language="VB" %>

<%@ Import Namespace="OSGeo.Mapguide" %>

 

<!-- #Include File="../UtilityFunctions.aspx" -->

 

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

 

<script runat="server">

    Private selectionXML as string

    Private MapDef As String = "Library://Kroll/Map/MGA.MapDefinition"

</script>

 

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

<head runat="server">

    <title>Untitled Page</title>

</head>

<body class="AppFrame" onLoad="OnPageLoad()">

 

<% 

 

    Try

        

        Dim SessionId As String = GetRequestParameters("SESSION")

        InitializeWebTier()

                

        Dim UserInfo As New MgUserInformation(SessionId)

        Dim site As New MgSite()

        site.Open(UserInfo)

        

        Dim siteconnection As New MgSiteConnection

        siteconnection.Open(UserInfo)

        dim ResourceService as mgresourceservice =
siteconnection.CreateService(MgServiceType.ResourceService)

       

        Dim MapDefId As New MgResourceIdentifier(MapDef)

        Dim MapName As String = MapDefId.Name

        Dim Map as New MgMap(siteconnection)

        Map.Open(ResourceService, MapName)

        

        Dim ParcelQuery As New MgFeatureQueryOptions

        ParcelQuery.SetFilter("FeatId = 66")

        

        Dim layer As MgLayer =
Map.GetLayers().GetItem("pslc_cov_121206web")

        dim FeatureService as mgfeatureservice =
siteconnection.CreateService(MgServiceType.FeatureService)

        Dim fr As MgFeatureReader = FeatureService.SelectFeatures(New
MgResourceIdentifier(layer.GetFeatureSourceId),
layer.GetFeatureClassName, ParcelQuery)

        

        layer = Map.GetLayers().GetItem("pslc_cov_121206web")

        Dim selection As New MgSelection(Map)

        selection.AddFeatures(layer, fr, 0)

        

        selection.Open(ResourceService, MapName)

        

        selectionXML = selection.ToXml()

        

        selection.Save(ResourceService, MapName)

        

        Map.Save(ResourceService)

        layer.ForceRefresh()

 

        

        'emit javascript to refresh map

        Dim scriptKey As String = "Refresh"

        If Not Page.ClientScript.IsStartupScriptRegistered(Me.GetType,
scriptKey) Then

            Dim javaScript As String =
"parent.parent.mapFrame.Refresh();parent.parent.mapFrame.location.reload
(true);"

            Page.ClientScript.RegisterStartupScript(Me.GetType,
scriptKey, javaScript, True)

        End If

        

        

    Catch ex As Exception

        Response.Write(ex.Message + "</br>" + ex.StackTrace)

    End Try

    

%>

 

</body>

 

<script language="javascript" type="text/javascript">

// Emit this function and assocate it with the onLoad event

// for the page so that it gets executed when this page

// loads in the browser. The function calls the

// SetSelectionXML method on the Viewer Frame, which updates

// the current selection on the viewer and the server.

function OnPageLoad()

{

    selectionXml = <%=selectionXml%>;

    parent.parent.SetSelectionXML(selectionXml);

    parent.parent.mapframe.refresh();

}

</script>

 

</html>

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


More information about the mapguide-users mailing list