怎样把GPS得到的经纬度转换为具体位置

怎样把GPS得到的经纬度转换为具体位置,第1张

1实现将一组GPS模块获取的经纬度数据在百度地图上绘制轨迹

2标准的GPS经纬度坐标直接在地图上绘制会有偏移,这是测绘局和地图商设置的加密,要转换成百度地图坐标,代码如下

@return 百度地图坐标

/

publicGeoPoint gpsToBaidu(String data) {//data格式 nmea标准数据 ddmmmmmmm,ddmmmmmm 如303090909,114491234

String[] p = datasplit(",");

intlat = (int) (((int) (FloatvalueOf(p[0]) /100) + (100 (Float//将ddmmmmmm格式转成ddddddd

valueOf(p[0]) /1000- (int) (FloatvalueOf(p[0]) /100)) /600)) 1E6);

intlon = (int) (((int) (FloatvalueOf(p[1]) /100) + (100 (Float

valueOf(p[1]) /1000- (int) (FloatvalueOf(p[1]) /100)) /600)) 1E6);

GeoPoint pt =newGeoPoint(lat, lon);

returnCoordinateConvertfromWgs84ToBaidu(pt);//转成百度坐标

}

- (void)locationManager:(CLLocationManager )manager

didUpdateToLocation:(CLLocation )newLocation

fromLocation:(CLLocation )oldLocation

{

if (!gaocoder) {

gaocoder = [[MKReverseGeocoder alloc]initWithCoordinate:newLocationcoordinate];

gaocoderdelegate =self;

[gaocoder start];

}

showmapviewregion=MKCoordinateRegionMake(selfbestloactioncoordinate, MKCoordinateSpanMake(0005f, 0005f));

showmapviewshowsUserLocation=YES;

showmapviewzoomEnabled=NO;

if (!selfbestloaction)selfbestloaction=newLocation;

else if (newLocationhorizontalAccuracy<bestloactionhorizontalAccuracy)

selfbestloaction=newLocation;

latitudeString= [[NSString alloc] initWithFormat:@"%g",newLocationcoordinatelatitude];

NSLog(@"string one:%@",latitudeString);

[latitudeString release];

longitudeString = [[NSString alloc]initWithFormat:@"%g",newLocationcoordinatelongitude];

NSLog(@"string two:%@",longitudeString);

[longitudeString release];

}

以上就是关于怎样把GPS得到的经纬度转换为具体位置全部的内容,包括:怎样把GPS得到的经纬度转换为具体位置、如何使用Core Location获取当前的位置和GPS的坐标、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/9532734.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-29
下一篇 2023-04-29

发表评论

登录后才能评论

评论列表(0条)

保存