Giter VIP home page Giter VIP logo

jzlocationconverter's Introduction

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

iOS Swift Xcode Carthage compatible CocoaPods License

Demo

使用

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

github "JackZhouCn/JZLocationConverter-Swift"

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

pod 'JZLocationConverterSwift'

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

    //默认边境线数据
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        JZLocationConverter.start { (error) in
            if error != nil {
                print("失败")
            }else {
                print("成功")
            }
        }
        return true
    }

或者

    //自定义边境线数据
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        JZLocationConverter.start(filePath: Bundle.main.path(forResource: "xx", 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、默认的大陆边境线数据范围

jzlocationconverter's People

Contributors

jackzhoucn avatar aiden-leong avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.