76
|
Chapter 5
Handling Events
We named the event observer
obs
. To call this observer for Netscape
Navigator, refer to the observer as
document.obs
, because in the Netscape
object model the observer is an object of the document. Be sure to copy the
Autodesk MapGuide Viewer Plug-In observer applet code
MapGuideObserver6.class
to the same directory as your HTML files, or
this code won’t work. If you were to embed
MapGuideObserver6.class
in
a different frame or window from the function where you called it, you will
need to specify the full
window.frame.document.object
name. For
example:
parent.mapframe.document.obs
.
Now, suppose you have a button named
Digitize
. This button is set up so
that its
onClick
even
t
(a browser event) calls a function you created,
DigitizeIt
. The
DigitizeIt
function calls the
digitizePoint
method,
an Autodesk MapGuide Viewer API method that waits for the user to click a
point on the map and then captures that point. For Netscape Navigator, the
digitizePoint
method requires an event observer as a parameter, whereas
Internet Explorer does not. Here is the code for both:
function digitizeIt()
{
if (navigator.appName == "Navigator")
getMap().digitizePoint(document.obs);
else
getMap().digitizePoint();
}
So if the user is viewing the map in Netscape, the observer applet
(
document.obs
) is passed as a parameter. The browser waits for the user to
click a point on the map, which triggers the
onDigitizedPoint
event.
Then, one of the two observers picks up the event and tells the browser what
function to call next, namely an event handler function you named
onDigitizedPoint
. The
onDigitizedPoint
function then does whatever
you want with the event, such as retrieving the coordinates of the point the
user clicked.
Summary of Contents for 15606-011408-9300 - MAP R6.3 UPG
Page 1: ...15306 010000 5060 October 2001 Autodesk MapGuide Release 6 Developer s Guide ...
Page 6: ...vi ...
Page 16: ...16 ...
Page 30: ...30 ...
Page 84: ...84 ...
Page 134: ...134 ...
Page 202: ...202 ...