2015-06-05 34 views
0

繪製的AGSPoint我綜合arcGis SDK來我iOS項目 而是試圖繪製agsPoint到某一點時,它總是密謀(0,0)。我想提前上AGSMapView的iOS

AGSSpatialReference *spatialRefference = [AGSSpatialReference spatialReferenceWithWKID: 102100]; 
// 4326 ,102100 

AGSPoint *newPoint=[[AGSPoint alloc]init]; 
//newPoint2= [AGSPoint pointWithX:75.871952 y:22.685667 spatialReference:spatialRefference]; 
//newPoint= [AGSPoint pointWithLocation:locInstance.locationManager.location]; 

[myMap zoomToResolution:2.0 withCenterPoint:newPoint animated:YES]; 

//1. Create Graphics Layer 
AGSGraphicsLayer* myGraphicsLayer = [[AGSGraphicsLayer alloc]initWithSpatialReference:newPoint.spatialReference]; 



[myMap addMapLayer:myGraphicsLayer withName:@"Graphics Layer"]; 

//2. Create a marker symbol to be used by our Graphic 
AGSSimpleMarkerSymbol *myMarkerSymbol =[AGSSimpleMarkerSymbol simpleMarkerSymbol]; 

myMarkerSymbol.color = [UIColor blueColor]; 
myMarkerSymbol.style = AGSSimpleMarkerSymbolStyleDiamond; 
myMarkerSymbol.outline.color = [UIColor whiteColor]; 
myMarkerSymbol.outline.width = 1; 

//3. Create an AGSPoint (which inherits from AGSGeometry) that 
//defines where the Graphic will be drawn 

AGSPoint* locPoint =[[AGSPoint alloc]init]; 

locPoint=[AGSPoint pointWithLocation:locInstance.bestEffortAtLocation]; 


AGSGeometryEngine* engine = [AGSGeometryEngine defaultGeometryEngine]; 

AGSGeometry *pointToDraw= [engine projectGeometry:locPoint            toSpatialReference:newPoint.spatialReference]; 

//4. Create the Graphic, using the symbol and 
//geometry created earlier 

//[AGSGraphic graphicWithGeometry:locPoint symbol:myMarkerSymbol attributes:attributes]; 

AGSGraphic* myGraphic = [[AGSGraphic alloc]init]; 
      myGraphic= [AGSGraphic graphicWithGeometry:pointToDraw symbol:myMarkerSymbol attributes:attributes]; 

[myGraphicsLayer addGraphic:myGraphic]; 
+0

AGSPoint * gpsPoint = [[AGSPoint頁頭] initWithX: gpsLocation.coordinate.longitude y:gpsLocation.coordinate.latitude spatialReference:[AGSSpatialReference wgs84SpatialReference]]; 現在它的工作! –

回答

0

我也面臨着同樣的問題,它是由於空間參考

感謝。我已經檢查過,

AGSPoint* gpsPoint = [[AGSPoint alloc] initWithX:gpsLocation.coordinate.longitude y:gpsLocation.coordinate.latitude spatialReference:[AGSSpatialReference wgs84SpatialReference]]; 

但它沒有爲我工作。我得到了這個link這完全適用於我的解決方案,你只需要轉換經度和緯度的地圖點X和Y.這裏是代碼,

//convert longitude and latitude to map point X Y 
double mercatorX = loc.coordinate.longitude * 0.017453292519943295 * 6378137.0; 
double a = loc.coordinate.latitude * 0.017453292519943295; 
double mercatorY = 3189068.5 * log((1.0 + sin(a))/(1.0 - sin(a))); 

AGSPoint *myMarkerPoint = [AGSPoint pointWithX:mercatorX y:mercatorY spatialReference:[AGSSpatialReference wgs84SpatialReference]];