arcgis js 获取距离和面积

Defines the type of calculation for the geometry. The type can be one of the following:
  • planar: Planar measurements use 2D Cartesian mathematics to calculate length. Use this type if the length needs to be calculated in the input spatial reference otherwise use preserveShape.
  • geodesic: Use this type to calculate an area or length using only the vertices of the polygon to define the lines connecting the vertices as geodesic segments independent of the actual shape of the polygon. Note: a geodesic segment is the shortest path between two points on an ellipsoid.
  • preserveShape: Calculate the area or length of the geometry on the surface of the Earth ellipsoid, for geometries defined in a projected or geographic coordinate system. This method preserves the shape of the geometry in its coordinate system which means the true area or length will be calculated for the geometry that is displayed on the map.

Requires ArcGIS Server 10.1 or greater (Added at v3.0)

Sample:

areasAndLengthParams.calculationType = 'preserveShape';
require([
  "esri/tasks/AreasAndLengthsParameters", "esri/tasks/GeometryService", ... 
], function(AreasAndLengthsParameters, GeometryService, ... ) {
  var areasAndLengthParams = new AreasAndLengthsParameters();
 areasAndLengthParams.calculationType = 'preserveShape';  areasAndLengthParams.areaUnit
= esri.tasks.GeometryService.UNIT_ACRES; ... });


posted @ 2024-08-20 16:11  恋上微笑的天使  阅读(2)  评论(0编辑  收藏  举报