android高德地图自动缩放比例,【Android】高德地图 缩放级别及像素以及地图上的点转化成屏幕上的点...

/** * 调节地图到正好放置查询范围的所有点 * @param centerLatLng 中心点 * @param range 查询范围(米) */

private void adjustCamera(LatLng centerLatLng,int range) {

//http://www.eoeandroid.com/blog-1107295-47621.html

//当前缩放级别下的比例尺

//"每像素代表" + scale + "米"

float scale = g_aMap.getScalePerPixel();

//代表range(米)的像素数量

int pixel = Math.round(range / scale);

//小范围,小缩放级别(比例尺较大),有精度损失

Projection projection = g_aMap.getProjection();

//将地图的中心点,转换为屏幕上的点

Point center = projection.toScreenLocation(centerLatLng);

//获取距离中心点为pixel像素的左、右两点(屏幕上的点

Point right = new Point(center.x + pixel, center.y);

Point left = new Point(center.x - pixel, center.y);

//将屏幕上的点转换为地图上的点

LatLng rightLatlng = projection.fromScreenLocation(right);

LatLng LeftLatlng = projection.fromScreenLocation(left);

LatLngBounds bounds = LatLngBounds.builder().include(rightLatlng).include(LeftLatlng).build();

//bounds.contains();

g_aMap.getMapScreenMarkers();

//调整可视范围

//aMap.moveCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder().include(rightLatlng).include(LeftLatlng).build(), 10)); }

}

代码片段,点击区域,显示该区域上的点

LatLng latLng = marker.getPosition();

//缩放级别

float zoom = g_aMap.getCameraPosition().zoom;

//"每像素代表" + scale + "米"

float scale = g_aMap.getScalePerPixel();

float range = scale * zoom;

Circle circle = g_aMap.addCircle(new CircleOptions().center(latLng)

.radius(range).strokeColor(getResources().getColor(R.color.color_translate))

.fillColor(getResources().getColor(R.color.color_translate)).strokeWidth(2));

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值