10. Measurement of ArcGIS Runtime SDK for iOS 100.X Tutorial Series

I searched in the official ArcGis documentation, but there is no measurement function demo found, only one similar:

https://developers.arcgis.com/ios/latest/swift/sample-code/distance-measurement-analysis/

At least from this official demo, we know that the class used for measurement is: AGSGeometryEngine, which provides a comprehensive distance and area measurement api, supports direct AGSGemetry input for calculation, and has a variety of measurement units to choose from. The main methods involved are :

//测距,传入AGSGeometry对象,并指定计算结果的单位,以及计算类型
//一般计算类型选择AGSGeodeticCurveTypeGeodesic即可
+ (double)geodeticAreaOfGeometry:(AGSGeometry*)geometry areaUnit:(AGSAreaUnit*)areaUnit curveType:(AGSGeodeticCurveType)curveType;
//测面积,传入AGSGeometry对象,并指定计算结果的单位,以及计算类型
//一般计算类型选择AGSGeodeticCurveTypeGeodesic即可
+ (double)geodeticLengthOfGeometry:(AGSGeometry*)geometry lengthUnit:(AGSLinearUnit*)lengthUnit curveType:(AGSGeodeticCurveType)curveType

There is a calculation method, but how to let users interact with drawing on the map? This actually uses the annotation sketch function mentioned in the previous blog. Use AGSSketchEditor to open the drawing function, and listen to the AGSSketchEditorGeometryDidChangeNotification notification to calculate the length or area of ​​the shape drawn by the user in real time.

The effect I made is as follows:

 

Guess you like

Origin blog.csdn.net/qq_31672459/article/details/103198858