CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

JZLocationConverterSwift 1.0.1

JZLocationConverterSwift 1.0.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Dec 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by jackzhou.



WGS-84世界标准坐标、GCJ-02中国国测局(火星坐标)、BD-09百度坐标系转换

iOS
Swift
Xcode
Carthage compatible
CocoaPods

Demo

使用

支持 Carthage,添加以下代码到你的Cartfile文件中:

github "JackZhouCn/JZLocationConverter-Swift"

1、在APP启动时加载大陆边境线数据

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        JZLocationConverter.start(filePath: Bundle(for:JZAreaManager.self).path(forResource: "GCJ02", ofType: "json")) { (error:JZFileError?) in
            if error != nil {
                print("失败")
            }else {
                print("成功")
            }
        }
        return true
    }

2、转换方法都在转换工具单例类内

    JZLocationConverter.default

3、目前有:

WGS-84 -> GCJ-02

此接口当输入坐标为中国大陆以外时,仍旧返回WGS-84坐标

    public func wgs84ToGcj02(_ wgs84Point:CLLocationCoordinate2D,result:@escaping (_ gcj02Point:CLLocationCoordinate2D) -> Void)

GCJ-02 -> WGS-84

此接口有1-2米左右的误差,需要精确的场景慎用

    public func gcj02ToWgs84(_ gcj02Point:CLLocationCoordinate2D,result:@escaping (_ wgs84Point:CLLocationCoordinate2D) -> Void)

WGS-84 -> BD-09

    public func wgs84ToBd09(_ wgs84Point:CLLocationCoordinate2D,result:@escaping (_ bd09Point:CLLocationCoordinate2D) -> Void)

BD-09 -> WGS-84

    public func bd09ToWgs84(_ bd09Point:CLLocationCoordinate2D,result:@escaping (_ wgs84Point:CLLocationCoordinate2D) -> Void) 

GCJ-02 -> BD-09

    public func gcj02ToBd09(_ gcj02Point:CLLocationCoordinate2D,result:@escaping (_ bd09Point:CLLocationCoordinate2D) -> Void)

BD-09 -> GCJ-02

此接口有1-2米左右的误差,需要精确的场景慎用

    public func bd09ToGcj02(_ bd09Point:CLLocationCoordinate2D,result:@escaping (_ gcj02Point:CLLocationCoordinate2D) -> Void)

关于大陆边境线数据

1、默认的边境线数据位于项目的GCJ02.json文件中

2、默认的边境线数据来自「百度地图」API并转换到GCJ02

3、如果你需要使用自己的边境线数据(需要GCJ02坐标),只需要在启动时加载自己的数据即可

4、默认的大陆边境线数据范围