Autodesk 15606-011408-9300 Developer Guide - Page 139
Custom Redlining Application, MGMapObject, addCirclePrimitive, addPolygonPrimitive, MGMapdigitize
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 139 highlights
onDigitizedPolygon Function (continued) var obj = layer.getMapObject(formText); if (obj == null) var obj = layer.createMapObject(formText, formText, ""); // create MGCollection that holds user-specified polygon vertices var user_vertices = map.createObject("mgcollection"); user_vertices.add(numPoints); // use MGCollection to create polyline primitive and add it to // redline object obj.addPolylinePrimitive(points, user_vertices, false); // clear contents of 'Polygon Name' text box document.the_form.the_textbox.value = ""; } The Save It! button calls a JavaScript function that saves the map to the user's hard drive. The function prompts the user for the map password, then calls the MGMap.saveMWF method, and saves the map to the specified path: function save_it() { var fName = "c:\\My Documents\\my_map.mwf"; var password = prompt("Please enter a password.", ""); if (getMap().saveMWF(fName, password) ) alert("Map has been saved!"); else alert("Unable to save map."); } The example above is a very simple application designed to illustrate redlining. However, your application can have more features, such as allowing users to add other primitives besides polygons. Also, you can exert more control over how the primitives appear on screen or to query the state of existing redline objects. To learn more about these topics, refer to the following sections in the Autodesk MapGuide Viewer API Help: I For information about creating primitives, look up the MGMapObject add methods (addCirclePrimitive, addPolygonPrimitive, and so on). Also look up the MGMapdigitize methods and their corresponding events. I For information about controlling the appearance of redline objects, look up MGEdgeAttr, MGFillAttr, MGLineAttr, MGSymbolAttr, MGTextAttr, and MGRedlineSetup. I For information about querying redline objects, look up MGPrimitive. Custom Redlining Application | 139