如果你在应用程序中使用Apple Maps的坐标,并且在mapkit中创建了CLLocation,请注意坐标系的不同之处。因此,需要将Apple Maps坐标转换为mapkit坐标。
下面是将Apple Maps坐标转换为mapkit坐标的示例代码:
// 获取Apple Maps的CLLocation
let appleMapsLocation = CLLocation(latitude: 37.3327, longitude: -122.0050)
// 将坐标转换为mapkit坐标
let mapKitLocation = appleMapsLocation.coordinate
// 创建一个新的CLLocation对象
let location = CLLocation(latitude: mapKitLocation.latitude, longitude: mapKitLocation.longitude)
如果需要在应用程序中使用Apple Maps坐标,请注意必须正确设置CLLocationCoordinate2DMake函数中的参数顺序。正确的参数顺序应该是维度,然后是经度。例如:
let coordinate = CLLocationCoordinate2DMake(37.3327, -122.0050)
如果按反向顺序传递参数,则坐标将不正确。