Skip to content

Instantly share code, notes, and snippets.

@lqik2004
Created November 27, 2012 16:04
Show Gist options
  • Save lqik2004/4155096 to your computer and use it in GitHub Desktop.
Save lqik2004/4155096 to your computer and use it in GitHub Desktop.
从真实GPS坐标获取百度地图坐标
CLLocationManager获取的坐标是由google坐标系得到的坐标,转化为百度坐标系百度有在官方API未公开实际存在的接口做转换。
/**
*坐标转换函数,从原始GPS坐标,mapbar坐标转换成百度坐标
*@param coorWgs84 待转换的原始GPS坐标,或者mapbar的坐标
*@return 返回的NSDictionry中包含“x”,“y”字段,各自对应经过base64加密之后的x,y坐标
*/
UIKIT_EXTERN NSDictionary* BMKBaiduCoorForWgs84(CLLocationCoordinate2D coorWgs84);
/**
*坐标转换函数,从google坐标,51地图坐标,mapabc坐标转换为百度坐标(51地图坐标需要显出10000)
*@param coorGcj 待转换的google坐标,51地图坐标,mapabc坐标
*@return 返回的NSDictionry中包含“x”,“y”字段,各自对应经过base64加密之后的x,y坐标
*/
UIKIT_EXTERN NSDictionary* BMKBaiduCoorForGcj(CLLocationCoordinate2D coorGcj);
/**
*base64加密后的坐标字典解密函数
*@param dictionary 带解密的NSDictionry,该NSDictionry中应包含“x”,“y”字段,各自对应经过base64加密之后的x,y坐标
*@return 解密之后的坐标
*/
UIKIT_EXTERN CLLocationCoordinate2D BMKCoorDictionaryDecode(NSDictionary* dictionary);
=================================================================
BMKCoorDictionaryDecode(BMKBaiduCoorForWgs84(Location));
======= Location为你通过CLLocationManager获取的坐标。=============
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment