Working with Map Features
|
59
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;
}
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);
}
doGet Coordinates Function
Содержание 15606-011408-9300 - MAP R6.3 UPG
Страница 1: ...15306 010000 5060 October 2001 Autodesk MapGuide Release 6 Developer s Guide ...
Страница 6: ...vi ...
Страница 16: ...16 ...
Страница 30: ...30 ...
Страница 84: ...84 ...
Страница 134: ...134 ...
Страница 202: ...202 ...