ios - 使用 arcgis iOS 经度和纬度显示位置结果不正确

标签 ios dictionary arcgis

全部

我是 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/

相关文章:

具有优先级的字符串中的Python搜索字典键

python - 可以像 JavaScript 一样定义函数吗?

c - 你知道支持 COW 事务的 C 字典吗?

ios - 如何使用 Swift 点击按钮或图像而不选择整个单元格?

objective-c - NSDate 和时区差异

ios - 如何在 iOS 模拟器中模拟本地/推送通知?

python - 我可以设置一个 python while 循环运行直到没有任何变化吗?

ios - 如何在保持图像纵横比的同时创建具有动态大小的图像网格/砂浆而不裁剪?

javascript - Arcgis (ESRI) dojo 导致使用 jQuery 的定义的组件进行 multipleDefine

javascript - 在 Arcgis map 上添加 Json 操作图层信息