根据网上查找的arcigs for js 1.5例子,可以测试出画面的面积和长度,但换成3.4版本后,根据官网例子做就不能计算,计算出的结果有误。
可查看博客
http://blog.csdn.net/ni_meri/article/details/8095844
也可以查看代码:
var areasAndLengthParams = new esri.tasks.AreasAndLengthsParameters();
// areasAndLengthParams.lengthUnit = esri.tasks.GeometryService.UNIT_KILOMETER;
// areasAndLengthParams.areaUnit = esri.tasks.GeometryService.UNIT_SQUARE_KILOMETERS;
areasAndLengthParams.lengthUnit = esri.tasks.GeometryService.UNIT_METER;
areasAndLengthParams.areaUnit = esri.tasks.GeometryService.UNIT_HECTARES;
var outSR = new esri.SpatialReference({ wkid: 102113});
geometryService.project([geometry],outSR,function(geometry){
//var m=me;
geometryService.simplify(geometry, function(simplifiedGeometries) {
areasAndLengthParams.polygons = simplifiedGeometries;
geometryService.areasAndLengths(areasAndLengthParams);
});
});
在1.5版本里需要设置
geometryService.project([graphic],new esri.SpatialReference({"wkid":102113}));
但在3.4版本里就没有这个
根据上面的博客我进行修改可以在3.4里 也需要 “进行投影转换”才能计算正确的面积
所以就有上面的代码