[Mapguide_users] Re: OnSelection Event?

Kori Maleski kmale at telus.net
Sat Jan 6 20:26:19 EST 2007


 

Jim,

The following descripe the methods I use:

In the mainframe.templ, insert a function call in the OneSelectionChanged 
Event:

function OnSelectionChanged() {

    var selCount = mapFrame.GetSelectedCount();

      SendSelection(); //ß------------------My new function call

    if(hasStatusbar == 1)

        sbFrame.SetFeatureSelectedMsg(FormatMessage((selCount > 
1? "__#FEATURESSELECTED#__": "__#FEATURESELECTED#__"), new Array
(selCount, "unused")));

    var stateChanged = false;

    for(var i = 0; i < selectionAwareCmds.length; i++)

...

 
Then add your new function:

 function SendSelection() {

      var selCount = mapFrame.GetSelectedCount();

      if(selCount != 0){

             if(hasTaskpane != 0){

                  GetTaskFrame().GetTaskPane().location.href = homePage.replace
("/MapGuide/MapViewerNet/","") + "?SESSION=" + mapFrame.GetSessionId() 
+ "&LOCALE=" + locale + "&MAPNAME=" + encodeURIComponent(mapFrame.GetMapName
()) + "&SELECTION=" + mapFrame.GetSelectionXML();

            }
         
      }
} 

 
In this instance, the designated homepage of the taskpane will be sent the 
specified UR parameters.

Following the edits to mainframe.templ – 

RESTART THE MAPGUIDE SERVER SERVICE – you may have to restart IIS or whatever 
webserver you are using.


In your recipient page (.NET flavour here:


Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 
Handles MyBase.Load

 
            Dim l_sSelect As String
            Dim l_sMapName As String
            Dim l_sSession As String

            l_sMapName = Request("MAPNAME")
            l_sSession = Request("SESSION")
            l_sSelect = Request("SELECTION")

            If l_sSelect <> "" Then

                'connect to the site
                Dim l_oCred As New MgUserInformation(l_sSession)
                Dim l_oSite As New MgSiteConnection()
                l_oSite.Open(l_oCred)
                'create services
                Dim l_oFeatureSrvc As MgFeatureService = l_oSite.CreateService
(MgServiceType.FeatureService)
                Dim l_oResourceSrvc As MgResourceService = 
l_oSite.CreateService(MgServiceType.ResourceService)
                'Create a temporary map runtime object, locate the layer
                Dim l_oMap As New MgMap()
                l_oMap.Open(l_oResourceSrvc, l_sMapName)
                'Create a Selection object for the selection XML
                Dim l_oSel As MgSelection = New MgSelection(l_oMap, l_sSelect)
                Dim l_cSelLayers As MgReadOnlyLayerCollection = 
l_oSel.GetLayers()

...
               

Then use the API to read the features as required.  
 

Cheers,

Kori Maleski



Quoting Jim O'Leary <joleary.public at gmail.com>:

> 
> Has anyone come up with a solution to the original question in this thread?
> How do you extract property names and values from the XML string that you
> get either from GetSelectionXML? 
> 
> Jason's clever code (May 4, 2006) captures the map's OnSelectionChanged
> event. You can then get the selections on the client side using
> GetSelectionXML(), which yields something like: 
> 
> <?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="ea15105a-ffff-ffff-8003-00a0d13b3329">  <Class id="MarkupSchema:Markup"> 
> 
> <ID>AQAAAA==</ID>  </Class> </Layer></FeatureSet> 
> 
> I'm assuming that you put the keys and values in this string in a query
> string and submit a form to the server to recreate this XML string. You
> could also write this XML to a uniquely named file and then pass the
> filename to the server. 
> 
> Assuming that you can recreate this XML string one way or the other on the
> server, how do you then extract name = value pairs from the feature(s) that
> you have selected? 
> 
> Thanks. 
> 
> 
> Willem Schwarte wrote:
> > 
> > I've just read the dev manual and want to try to create a little test
> > program, to get me started on understanding the flow of events etc.. 
> > 
> >  
> > 
> > What I want is:
> > 
> >  
> > 
> > When something gets selected, read a property and call an asp-page in
> > another frame (in short).
> > 
> >  
> > 
> > But how can I tell if something is selected?
> > 
> > I suppose there is no onSelectionChanged event like in MG6.5. So this
> > would be done on a onClick? Where would I put the code for this?
> > 
> >  
> > 
> > Willem
> > 
> >  
> > 
> > 
> > 
> 
> -- 
> View this message in context:
> http://www.nabble.com/OnSelection-Event--tf1561860.html#a8199139
> Sent from the MapGuide Users mailing list archive at Nabble.com.
> 
> _______________________________________________
> 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