[mapguide-users] Custom OnSelection Events - a better way?

Chris Tallman ctallman at innomap.com
Thu Mar 1 08:50:30 EST 2007


Brad,
 
I've been messing with this code and I have a question. 
 
The page that your code forwards to, how does that page access the data
from the selected object?  Do you use a query string request or is it
easier than that?
 
Chris

________________________________

From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Brad
Leighninger
Sent: Wednesday, February 28, 2007 2:48 PM
To: MapGuide Users Mail List
Subject: RE: [mapguide-users] Custom OnSelection Events - a better way?



On that same post Jason Birch wrote an override for the
OnSelectionChanged Event and placed it in the page where he called his
viewer.

 

http://www.nabble.com/RE%3A-OnSelection-Event--p4242868s16610.html

 

This should modify the event to run custom code in that instance of the
viewer only.

 

I modified it a bit to check to make sure only one item was selected and
to send the sessionID to a custom page where the api is used to get the
map and its selection set to display the data.  I think you need to use
a full URL to call your custom page because a relative URL will be
relative to the viewer application.  This has worked well for me in the
AJAX viewer.  Jason stated that it will not work in the DWF viewer but I
haven't tried it.

 

function MyOnSelectionChangedHandler()

        {

            originalOnSelectionChanged();

            var mapFrame=ViewerFrame.GetMapFrame();

            var selCount=mapFrame.GetSelectedCount();

            if(selCount==1)

            {

                var sessionID=mapFrame.GetSessionId()
parent.tabspage.selecteddetails.location.href="http://mysite/mypage.aspx
?sessionID="+sessionID

            }

        }

 

Brad Leighninger

Mathews & Associates, Inc.

417-869-6009

________________________________

From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Buscher,
Shane
Sent: Wednesday, February 28, 2007 1:01 PM
To: Mapguide_users at lists.osgeo.org
Subject: [mapguide-users] Custom OnSelection Events - a better way?

 

I needed a way to capture a selected feature, get it's attributes, then
show the results in the task frame.  I was able to achieve this by
customizing the OnSelectionChanged javascript function in the
mainframe.templ (thanks to Kori
http://www.nabble.com/OnSelection-Event--tf1561860s16610.html#a4241783
<http://www.nabble.com/OnSelection-Event--tf1561860s16610.html#a4241783>
).  The Viewer API does not expose this event, so the downside is that
you're forced into modifying MapGuide source code that will get executed
for all applications.   I'm developing in an enterprise environment, so
I need to be careful with dabbling in 3rd party source code and want to
avoid unexpected results with other applications that we'll write.  If I
(or someone else) ever did a reinstall of the web extensions and forgot
there was a customized mainframe.templ, we'd be hosed.  Is there any
better way to handle this?

Regards,

Shane

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


More information about the mapguide-users mailing list