iOS中ArcGIS地图的当前位置问题

iOS中ArcGIS地图的当前位置问题,ios,swift,arcgis,Ios,Swift,Arcgis,我正在开发一个有地图的应用程序。我正在使用ArcGIS SDK显示地图。在这里,我试图在地图加载时显示我的当前位置。我已将纬度和经度传递给ArcGIS函数的x和y参数。这是该函数的代码 let lat = gpsLocation.location?.coordinate.latitude let lng = gpsLocation.location?.coordinate.longitude print(lat) print(lng) //zoom to custom view point

我正在开发一个有地图的应用程序。我正在使用ArcGIS SDK显示地图。在这里,我试图在地图加载时显示我的当前位置。我已将纬度和经度传递给ArcGIS函数的
x
y
参数。这是该函数的代码

let lat = gpsLocation.location?.coordinate.latitude
let lng = gpsLocation.location?.coordinate.longitude

print(lat)
print(lng)

//zoom to custom view point
self.mapView.setViewpointCenter(AGSPoint(x: lat!, y: lng!, spatialReference: AGSSpatialReference.webMercator()), scale: 4e7, completion: nil)

self.mapView.interactionOptions.isMagnifierEnabled = true
但当我运行应用程序时,它会在地图上显示错误的位置。它指向错误的位置。我还打印了lat和lng。它们是正确的,但地图上位置的显示是错误的。如何获取地图以加载我的当前位置

这是加载时显示位置的内容


您使用的是纬度和经度,即若干度(可能在WGS 1984中),但随后您告诉ArcGIS它们在Web Mercator中,即若干米。这肯定会导致你看到的行为

要修复它,只需将
webMercator()
替换为
WGS84()

而且,你把纬度和经度弄混了。纬度是y,经度是x,反过来就是

总之,将您的
setViewpointCenter
调用替换为以下内容:

self.mapView.setViewpointCenter(
    AGSPoint(x: lon!, y: lat!, spatialReference: AGSSpatialReference.WGS84()),
    scale: 4e7,
    completion: nil
)

我已经在代码self.mapView.setViewpointCenter(AGSPoint(x:lat!,y:lng!,spaceReference:AGSSpatialReference.wgs84()),scale:4e7,completion:nil)中完成了这项工作。但它仍然没有显示我的当前位置区域@Gary S.我刚刚意识到你也混淆了纬度和经度。我编辑了这个问题以反映这一点。如果仍有问题,请验证打印语句是否仍在打印。(请注意
AGSSpatialReference.wgs84()
应导致编译错误。它是
AGSSpatialReference.wgs84()