JZLocationConverterSwift 1.0.1

JZLocationConverterSwift 1.0.1

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布最后发布2017年12月
SwiftSwift 版本3.0
SPM支持 SPM

jackzhou 维护。



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

iOS
Swift
Xcode
Carthage compatible
CocoaPods

示例

使用

支持 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、默认的大陆边境线数据范围