Autodesk 15606-011408-9300 Developer Guide - Page 59
doGet Coordinates Function, layer and assign it to a variable named
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 59 highlights
doGet Coordinates Function var cntVertices = map.createObject("MGCollection"); var res = obj.getVertices(vertices, cntVertices); if (res == 0) { alert("No access to coordinate information."); return; } msg = "Parcel:" + obj.getKey() + "\n"; msg = msg + "Coordinates in MCS unit\n"; for(var i = 0; i < cntVertices.item(0); i++) { var pnt = vertices.item(i); msg = msg + pnt.getX() + "," + pnt.getY() + "\n"; } alert(msg); } The doGetCoordinates function starts by using getMap to get an instance of the map; then it gets the current selection and assigns it to the sel variable: var map = getMap(); var sel = map.getSelection(); Then doGetCoordinates uses the getMapLayer method to select the Parcels layer and assign it to a variable named layer; if the Parcels layer doesn't exist in the map, an alert displays and the function terminates: var layer = map.getMapLayer("Parcels"); if (layer == null) { alert("No Parcels layer found in this map."); return; } Next, doGetCoordinates uses the getNumObjects and getMapObjectsEx methods to verify that one, and only one, feature is selected, and that the current layer is not empty. If the criteria are not met, an alert displays and the function terminates: if ( (sel.getNumObjects() > 1) || (sel.getNumObjects() == 0) || (sel.getMapObjectsEx(layer).size() == 0) ) { alert("Select only one parcel, please."); return; } Working with Map Features | 59