Autodesk 15606-011408-9300 Developer Guide - Page 80
onBeginLayout, MG Setup, MGPrintInfo, object and an
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 80 highlights
3 Write the event handler. It goes in the HTML page (or the JavaScript .js file), just like any other JavaScript function. This function is executed automatically every time the onBeginLayout event fires. Note that the function takes an MGPageSetup object and an MGPrintInfo object as its parameters: function onBeginLayout (pgSetup, info) { if (map_only == "true") { pgSetup.setInclude("mg_legend", false); pgSetup.setInclude("mg_northarrow", false); pgSetup.setInclude("mg_scalebar", false); pgSetup.setInclude("mg_title", false); pgSetup.setInclude("mg_timestamp", false); pgSetup.setInclude("mg_url", false); } } The following code shows how to implement the same event handler for the onBeginLayout event in Java: public class MyObserver extends Applet implements MGPrintingObserver { public void onBeginLayout(MGPageSetup pgSetup, MGPrintInfo info) { // turn off all elements except the map pgSetup.setInclude("mg_scalebar", false); pgSetup.setInclude("mg_northarrow", false); pgSetup.setInclude("mg_title", false); pgSetup.setInclude("mg_timestamp", false); pgSetup.setInclude("mg_legend", false); } } Note You can control the Page Setup without using the onBeginLayout event, but the results are different. In the example above, the Page Setup is modified only for that printout. Because the event handler is working with a copy of the MGPageSetup object, subsequent printouts from the popup menu don't show these changes, and the changes don't appear in the Page Setup dialog box. If you were to write a similar function that was not attached to the onBeginLayout event, the changes would continue to be reflected in both the printout and the Page Setup dialog box until the map is refreshed. 80 | Chapter 5 Handling Events