Autodesk 15606-011408-9300 Developer Guide - Page 56
Working with Map Features, Getting Keys of Selected Map Features
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 56 highlights
Working with Map Features This section describes common tasks your application can perform with Autodesk MapGuide map features. Getting Keys of Selected Map Features In this example, the doGetKey function displays a dialog box showing the keys of selected map features (keys are unique values that are used to identify individual map features). If no features are selected, an alert displays prompting the user to make a selection: function doGetKey() { var map = getMap(); if (map.getSelection().getNumObjects() == 0) { alert ("Please make a selection first."); return; } var sel = map.getSelection(); var objs = sel.getMapObjectsEx(null); var cntObjects = objs.size(); var msg = "Keys of selected features are:\n"; var i; for (i = 0; i < cntObjects; i++) { var obj = objs.item(i); var key = obj.getKey(); msg = msg + obj.getMapLayer().getName() + " " + key + "\n"; } alert(msg); } The function starts by getting an instance of the MGMap object: var map = getMap(); Then it uses two API methods to see if any map features are selected. Note that the methods are concatenated; the first method, getSelection, operates on the map and returns a selection object, which is then passed to the second method, getNumObjects, for processing. If no map features are selected, an alert displays and the function terminates; otherwise, the selection is assigned to the sel variable: if (map.getSelection().getNumObjects() == 0) { alert ("Please make a selection first."); return; } var sel = map.getSelection(); 56 | Chapter 4 Working with Map Layers, Map Features, and Printing