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

Buscher, Shane Shane.Buscher at nngco.com
Wed Feb 28 17:42:35 EST 2007


Thanks Brad.  I didn't realize you could override a javascript method in
this fashion.  I completely overlooked this post which I did read, but
obviously didn't understand!

 

-shane

 

________________________________

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 1: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/20070228/54cc2a3f/attachment-0001.html


More information about the mapguide-users mailing list