[mapguide-users] Ajax Viewer Events
Scott McFarlane
scott at geotropix.com
Tue Mar 13 09:03:09 EDT 2007
GM,
I've seen several solutions to this problem on this list, but most of them
seem to require that you modify the built-in ajax viewer template files,
which I personally don't like to do.
As long as your status bar frame comes from the same web server as the
viewer, and stays visible during the session, the following method should
work. This method accomplishes the same thing as modifying the source code
of the template files, but instead it is done at run-time. The basic concept
is that you make a copy of the original OnSelectionChanged function (found
in the main frame) and then you redefine it with your own code, which in
turn, calls the original copied function.
In your status bar page, you can put the following JavaScript code. You'll
need to ensure that the main frame for the ajax viewer is loaded before this
code executes, so depending on how your overall page loads, this code may
need to be wrapped into a function that waits until it knows the main frame
is available.
// This needs to find the main frame of the ajax viewer
// It depends on the relationship of this frame with other frames
var main = parent.parent;
// Copy the original OnSelectionChanged function
if(typeof main.osc == 'undefined')
main.osc = main.OnSelectionChanged;
main.OnSelectionChanged = function()
{
// Add your code here
// ...
// Call the original function
main.osc();
}
Hope this helps,
- Scott
-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of GM_Mizar
Sent: Tuesday, March 13, 2007 5:20 AM
To: mapguide-users at lists.osgeo.org
Subject: [mapguide-users] Ajax Viewer Events
Another time here with another boring problem, this time regarding the AJAX
viewer.
I have a status bar external to the viewer, here I can write messages for
the user. I want to write here the description of the selected object but I
want that this description changes when I select a new object in the map.
I'm trying to catch the "selection" event but I haven't found any viewer API
to perform this operation. I've also checked the html code of the property
panel, I've seen that the javascript function "SetProperties" is called each
time ore or more object are selected.
I'm thinking about replacing the page of the property panel with one which
contains the same function "SetProperties", here I can update my external
status bar. Unfortunately this solution has two disadvantages:
1) the property panel should be visible (and I don't want it)
2) I have to change a file under the installation folder of the
MapGuide
server (exactly the
"\WebServerExtensions\www\mapviewernet\propertyctrl.aspx"), this can create
problems in deployment and maintenance of the application
Now the questions:
1) can I catch the event related to the selection of an object in the
Ajax
Viewer?
2) if not, is it possible to change the link of the page shown in the
property panel?
Thanks a lot for replies.
GM
--
View this message in context:
http://www.nabble.com/Ajax-Viewer-Events-tf3394731s16610.html#a9450716
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