Cocoapods支援
pod 'HZLocationConverter'
複製程式碼
常見的座標轉換方式
/**
* 判斷是否在中國
*/
+(BOOL)isLocationOutOfChina:(CLLocationCoordinate2D)location;
/**
* 將WGS-84轉為GCJ-02(火星座標):
*/
+(CLLocationCoordinate2D)transformFromWGSToGCJ:(CLLocationCoordinate2D)wgsLoc;
/**
* 將GCJ-02(火星座標)轉為WGS-84:
*/
+(CLLocationCoordinate2D)transformFromGCJToWGS:(CLLocationCoordinate2D)p;
/**
* 將GCJ-02(火星座標)轉為百度座標:
*/
+(CLLocationCoordinate2D)transformFromGCJToBaidu:(CLLocationCoordinate2D)p;
/**
* 將百度座標轉為GCJ-02(火星座標):
*/
+(CLLocationCoordinate2D)transformFromBaiduToGCJ:(CLLocationCoordinate2D)p;
複製程式碼
- 專案地址
https://github.com/MyHZ/HZLocationConverter
- Demo地址
https://github.com/MyHZ/HZLocationConverterExample
- 簡書地址
https://www.jianshu.com/p/dfa621aaf497