1,iOS百度地图坐标系转换----百度To谷歌
<span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(122, 72, 47);">UIKIT_EXTERN</span> <span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(115, 64, 163);">NSDictionary</span>* BMKBaiduCoorForWgs84(<span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(115, 64, 163);">CLLocationCoordinate2D</span> coorWgs84); <span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(122, 72, 47);">UIKIT_EXTERN</span><span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(0, 0, 0);"> </span>NSDictionary<span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(0, 0, 0);">* BMKBaiduCoorForGcj(</span>CLLocationCoordinate2D<span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(0, 0, 0);"> coorGcj);</span> <span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(122, 72, 47);">UIKIT_EXTERN</span> <span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(115, 64, 163);">CLLocationCoordinate2D</span> BMKCoorDictionaryDecode(<span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(115, 64, 163);">NSDictionary</span>* dictionary);
<span style="word-wrap: normal; word-break: normal; line-height: 19.5px; color: rgb(126, 72, 48);">#import </span>"GTMBase64.h"
- (CLLocationCoordinate2D )getBaiduFromGoogle:(CLLocationCoordinate2D )locationCoord { NSDictionary *baidudict =BMKBaiduCoorForGcj(CLLocationCoordinate2DMa<wbr>ke(locationCoord.latitude, locationCoord.longitude)); NSLog(@"google坐标是:%f,%f",locationCoord.latitude,locationCoord.longitude); NSString *xbase64 =[baidudict objectForKey:@"x"]; NSString *ybase64 = [baidudict objectForKey:@"y"]; NSData *xdata = [GTMBase64 decodeString:xbase64]; NSData *ydata = [GTMBase64 decodeString:ybase64]; NSString *xstr = [[NSString alloc] initWithData:xdata encoding:NSUTF8StringEncoding]; NSString *ystr = [[NSString alloc] initWithData:ydata encoding:NSUTF8StringEncoding]; CLLocationCoordinate2D result; result.latitude =[ystr floatValue]; result.longitude = [xstr floatValue]; NSLog(@"百度坐标是:%f,%f",result.latitude,result.longitude); return result; } </wbr>
百度坐标和GPS坐标转换在很近的距离时偏差非常接近。
把这个坐标当成GPS坐标,通过接口获得他的百度坐标:x2=116.41004950566,y2=39.916979519873
通过计算就可以得到GPS的坐标:
x = 2*x1-x2,y = 2*y1-y2
x=116.38480649434001
y=39.901480480127
下面是使用objective-c实现的Web墨卡托坐标与WGS84坐标互转程序,当然也可以使用其他语言来实现,使用起来比较简单和方便。
//经纬度转墨卡托
-(CGPoint )lonLat2Mercator:(CGPoint ) lonLat
{
}
//墨卡托转经纬度
-(CGPoint )Mercator2lonLat:(CGPoint ) mercator
{
}
WGS 84 坐标单位是度,其中,第一个坐标是经度,范围是 -180 到 180;第二个坐标是纬度,范围是 -90 到 90。
WGS 84 的缺省测量单位是米,是球形地球类型的空间参照系。
4,GPS to ArgGIS实例(ArcGIS for iOS)
// 定位
@property (nonatomic, retain) CLLocationManager *LocationMan;
@property (nonatomic, retain) AGSGraphic *LocationPin;
- (IBAction)MapLocationBtnTouched:(id)sender
{
}
#pragma mark - CLLocationDelegate Methods
// (__MAC_10_6, __MAC_NA, __IPHONE_2_0, __IPHONE_6_0)
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
}
// __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
}
- (CGPoint)lonLat2Mercator:(CGPoint)lonLat
{
}
- (void)createLocationPin:(CLLocation *)location
{
}
- (void)locationManager:(CLLocationManager *)manager
{
}
NSString *TStr =@"http://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer";
// 如果TStr中有汉字的话, 要执行下面代码, 下面这个服务只是测试, 无此服务.
//
//