高德坐标转换百度坐标

func BD09FromGCJ02(_ coor:CLLocationCoordinate2D) ->CLLocationCoordinate2D{
  let x_pi = 3.14159265358979324*3000.0/180.0

  let x = coor.longitude, y = coor.latitude

  let z = sqrt(x * x + y * y) +0.00002*sin(y * x_pi)

  let theta = atan2(y, x) +0.000003*cos(x * x_pi)

  let bd_lon = z * cos(theta) + 0.0065

  let bd_lat = z * sin(theta) + 0.006

  return CLLocationCoordinate2D(latitude: bd_lat, longitude: bd_lon)

}

你可能感兴趣的:(高德坐标转换百度坐标)