Autodesk 15606-011408-9300 Developer Guide - Page 138
Applications, polygon vertices, and the coordinates of those vertices.
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 138 highlights
The Add/Update Polygon button calls a JavaScript function that lets the user draw a polygon by digitizing points on the map. The function first checks to see if there's a value in the Polygon Name check box. If there is a value, the function calls either the digitizePolygon or digitizePolygonEx method. Otherwise, the function displays an alert and exits: function add_pgon() { // get map object var map = getMap(); // exit function if 'Polygon Name' text box is empty if (document.the_form.the_textbox.value == "") { alert("Please enter a polygon name.") return; } // if browser is Netscape, use 'Ex' version and pass // observer applet; if browser is Internet Explorer, // use 'non-Ex' version with no argument if (navigator.appName == "Netscape") map.digitizePolygonEx(document.obs); else map.digitizePolygon(); } The digitizePolygon and digitizePolygonEx methods both fire the onDigitizedPolygon event, passing it the map object, the number of polygon vertices, and the coordinates of those vertices. The onDigitizedPolygon event looks for a JavaScript function of the same name and, if that function exists, executes it. In fact, the onDigitizedPolygon function does exist, because we've created it. Here's the code for that function: onDigitizedPolygon Function function onDigitizedPolygon(map, numPoints, points) { // create variable and assign it user-specified value // from 'Polygon Name' text box var formText = document.the_form.the_textbox.value; // create redline layer, or get it if it already exists var layer = map.getMapLayer("My Redline Layer"); if (layer == null) layer = map.createLayer("redline", "My Redline Layer"); // create redline object or get it if it exists (getMapObject // takes an object key as its value, while createMapObject // takesa key and a name -- the formText variable supplies // both of those values) 138 | Chapter 7 Applications