这个是利用接口转的博客
https://blog.csdn.net/qq_26708777/article/details/52807873
这是代码转gps的博客
https://blog.csdn.net/u013541140/article/details/50517354
我将二者融合了利用本地的百度sdk进行转
先代码获取百度location
bdLocationListener = new BDLocationListener() {
@Override
public void onReceiveLocation(final BDLocation arg0) {
}
}
把获取到的百度location当成gps转成百度坐标按2链接提供的方法,再按1链接提供的公式转换location
private LatLng getgpsfrombaidu(double latitude,double longitude){
LatLng sourceLatLng=new LatLng(latitude,longitude);
// 将GPS设备采集的原始GPS坐标转换成百度坐标
CoordinateConverter converter=new CoordinateConverter();
converter.from(CoordinateConverter.CoordType.GPS);
// sourceLatLng待转换坐标
converter.coord(sourceLatLng);
LatLng desLatLng = converter.convert();
return desLatLng;
}
LatLng latLng= getgpsfrombaidu(arg0.getLatitude(),arg0.getLongitude());
Util.bdLocation.la =2*arg0.getLatitude()- latLng.latitude;//doubleFormat(pOut.x, 6);
Util.bdLocation.lo = 2*arg0.getLongitude()-latLng.longitude;