Android 高德地图坐标转换

 

1、其他坐标系转到高德坐标系

支持GPS/Mapbar/Baidu等多种类型坐标在高德地图上使用。参见类CoordinateConverter。

CoordinateConverter converter  = new CoordinateConverter(); 
// CoordType.GPS 待转换坐标类型
converter.from(CoordType.GPS); 
// sourceLatLng待转换坐标点 LatLng类型
converter.coord(sourceLatLng); 
// 执行转换操作
LatLng desLatLng = converter.convert();

2、经纬度坐标与屏幕像素坐标互转

支持经纬度坐标与屏幕像素坐标互转。具体用法为:

用法列表

名称

说明

AMap.getProjection().fromScreenLocation(android.graphics.Point paramPoint)

根据转入的屏幕位置返回一个地图位置(经纬度)

AMap.getProjection().toScreenLocation(LatLng paramLatLng)

返回一个从地图位置转换来的屏幕位置

AMap.getProjection().toOpenGLWidth(int screenWidth)

返回一个屏幕宽度转换来的openGL 需要的宽度

AMap.getProjection().toOpenGLLocation(LatLng paramLatLng)

返回一个从经纬度坐标转换来的opengles 需要的坐标

3、CoordType属性

名称

说明

CoordType.ALIYUN

阿里云

CoordType.BAIDU

百度

CoordType.GOOGLE

谷歌

CoordType.MAPABC

MapABC(图盟科技)

CoordType.MAPBAR图吧地图
CoordType.SOSOMAP搜搜地图

4、举例:给marker添加新坐标值

 LatLng desLatLng = converter.convert();
            markerOption = new MarkerOptions().icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(), R.mipmap.ic)))
                    .position(desLatLng)
                    .draggable(true);
            markerOption.title(bean.getFeatures().get(i).getProperties().getSb_id());
            aMap.addMarker(markerOption);
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值