你首先必須建立和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
來源
2015-12-25 08:14:23
ddc