【发布时间】:2016-08-01 08:05:29
【问题描述】:
我想将用户当前位置与其他位置进行匹配,无论它们是否相同。
我的逻辑:
point.coordinate = coordinate
let userLat = mapView.userLocation?.coordinate.latitude
let userLong = mapView.userLocation?.coordinate.longitude
if point.coordinate.latitude == userLat && point.coordinate.longitude == userLong
{
point.title = "You are here"
}
else
{
point.title = "\(coordinate.latitude), \(coordinate.longitude)"
}
但问题是,mapView.userLocation?.coordinate.latitude 不等于 point.coordinate.latitude。但是我在模拟器和其他坐标中为 userLocation 设置了相同的值。
我为用户位置设置的值是: 纬度:28.6 长:77.35
我为其他坐标设置的值是: 纬度:28.6 长:77.35
我从用户位置获得的价值是: 纬度:可选 - 一些:3.4028234663852886e+38
长:▿ 可选 - 一些:3.4028234663852886e+38
我得到的其他坐标值是: 纬度:28.6 长:77.35
如果有更好的逻辑来找出这件事,那么请告诉我。
【问题讨论】:
标签: ios google-maps maps mapkit mapbox