Autodesk 15606-011408-9300 Developer Guide - Page 76
Autodesk MapGuide Viewer Plug-In observer applet code
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 76 highlights
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 event (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. 76 | Chapter 5 Handling Events