全部
我是 arcgis for iOS 的新手,现在遇到了一个奇怪的问题,我已经研究了其他线程,但没有找到任何解决方案。
我想在图形图层上显示一栋经度为 116.929167、纬度为 34.727222 的建筑物。我的 basemap 图层位于 WGS84 空间引用。
但是,当我第一次尝试以下代码时,它导致点错位。 注:该地点位于中国江苏省某地,但被放置在中国湖南省。
//create an instance of a tiled map service layer
AGSTiledMapServiceLayer *tiledLayer = [[AGSTiledMapServiceLayer alloc] initWithURL:[NSURL URLWithString:kTiledMapServiceURL]];
//Add it to the map view
[self.mapView addMapLayer:tiledLayer withName:@"Tiled Layer"];
//release to avoid memory leaks
//set the callout delegate so we can display callouts
self.mapView.callout.delegate = self;
//add graphics layer for the graphics
self.graphicsLayer = [AGSGraphicsLayer graphicsLayer];
//add the graphics layer to the map
[self.mapView addMapLayer:self.graphicsLayer withName:@"Graphics Layer"];
//zoom to china
AGSEnvelope *chinaEnv = [AGSEnvelope envelopeWithXmin:78.0000000
ymin:0.4400000
xmax:156.0000000
ymax:75.0000000
spatialReference:[AGSSpatialReference wgs84SpatialReference]];
[self.mapView zoomToEnvelope:chinaEnv animated:YES];
self.mapView.callout.customView = nil;
self.mapView.callout.accessoryButtonHidden = YES;
double longitude = 116.929167;
double latitude = 34.727222;
AGSPoint *graphicPoint = [AGSPoint pointWithX:longitude y:latitude spatialReference:[AGSSpatialReference wgs84SpatialReference]];
[self.mapView.callout showCalloutAt:graphicPoint screenOffset:CGPointMake(0, 0) animated:YES];
谁能告诉我为什么它无法显示正确的位置以及如何解决这个问题? 非常感谢您的时间和答复! 谨致问候。
最佳答案
恐怕您混淆了 WGS84 Web Mercator 和 WGS84。
- WGS84 Web Mercator:它是一个投影坐标系,被大多数世界地图(google、esri、bing)使用
- WGS84:纬度/经度
回到您的问题,我认为您的 basemap 是 WGS84 Web 墨卡托。但您的 map 点是 wgs84SpatialReference。你必须转换它。
希望这能解决您的问题。
关于ios - 使用 arcgis iOS 经度和纬度显示位置结果不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20671861/