从纬度和经度在ArcGIS IOS地图上绘制多边形对象

时间:2015-01-20 21:39:48

标签: iphone ipad arcgis

我是ArcGIS IOS地图的新手。我需要知道在ArcGIS Map上绘制多边形对象的正确方法

  1. 如何转换多边形点[Latitude&经度]到基地 图层特殊参考?
  2. 如何转换多边形点[Latitude&经度] ArcGIS map需要AGSPoint
  3. 如果有人分享这些点解释的工作示例代码会很好,这样我就可以从纬度和经度上绘制地图上的多边形对象。

    谢谢!

1 个答案:

答案 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];

ESRI's github

上有很多样本