我是ArcGIS IOS地图的新手。我需要知道在ArcGIS Map上绘制多边形对象的正确方法
ArcGIS map
需要AGSPoint
?如果有人分享这些点解释的工作示例代码会很好,这样我就可以从纬度和经度上绘制地图上的多边形对象。
谢谢!
答案 0 :(得分:1)
首先必须从纬度和经度构建和AGSPolygon对象,然后将整个多边形投影到基础层的空间参考:
AGSMutablePolygon *polygon = [[AGSMutablePolygon alloc] initWithSpatialReference:[AGSSpatialReference wgs84SpatialReference]];
[polygon addRingToPolygon];
for (int i = 0; i < [lats count]; i++) {
double lat = [lats objectAtIndex:i];
double lon = [lons objectAtIndex:i];
//Sub question 2)'s answer
AGSPoint *point = [[AGSPoint alloc] initWithX:lon y:lat spatialReference:[AGSSpatialReference wgs84SpatialReference]];
[polygon addPointToRing:point];
}
AGSGeometryEngine *geometryEngine = [AGSGeometryEngine defaultGeometryEngine];
AGSSpatialReference *sr = [[mapView baseLayer] spatialReference];
AGSPolygon *projpolygon = (AGSPolygon *)[geometryEngine projectGeometry:polygon toSpatialReference:sr];
然后,您可能想要构建一个AGSGraphic对象并将其添加到AGSGraphicsLayer中,不要忘记指定它的空间参考。
您还可以使用基础层的空间参考初始化多边形,并在添加之前逐个投影每个点:
//Sub question 1)'s answer
AGSPoint *projPoint = (AGSPoint *)[geometryEngine projectGeometry:wgsPoint toSpatialReference:sr];
上有很多样本