Swift工具开发
Swift Core Location 国内坐标偏移
Core Location 返回 WGS-84 坐标,而国内地图通常使用 GCJ-02;显示位置前需要识别数据来源和目标坐标系。
Aug 7, 2024 1 min read
Leave a thought
Comments live in GitHub Issues. Chinese and English pages share one conversation.
Loading comments…
Core Location 返回 WGS-84 坐标,而国内地图通常使用 GCJ-02;显示位置前需要识别数据来源和目标坐标系。
Comments live in GitHub Issues. Chinese and English pages share one conversation.
CLLocationManager返回的坐标基于 WGS-84,而国内互联网地图通常使用 GCJ-02。把 WGS-84 坐标直接绘制到 GCJ-02 地图上,就会出现肉眼可见的位置偏移。需要区分两种情况:
CLLocationCoordinate2D交给第三方国内地图或后端服务时,需要确认目标坐标系。如果目标使用 GCJ-02,可以在边界判断后进行 WGS-84 → GCJ-02 转换。现成实现可参考 JZLocationConverter-Swift。