Android按缩放级别增加折线宽度(Google Maps V2) [英] Android increase polyline width by zoom level (Google Maps V2)

查看:99
本文介绍了Android按缩放级别增加折线宽度(Google Maps V2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Google Maps V2上进行放大和缩小时,是否可以自动增加和减少折线的宽度?

Is there a way how I can automatic increase and decrease the width of a polyline when I zoom in and out on Google Maps V2?

当它保持极薄时,它看起来特别可怕,特别是在更新的设备上.但是您需要缩小时的厚度.

It looks horrible especially on newer devices when it stays so extremely thin. But you need it that thin when zoomed out.

推荐答案

将折线添加到地图后,将其保存.然后在折线上执行操作.

Save the polyline when it is added to the map. Then perform actions on the polyline.

将折线添加到地图后将其保存到数组列表的示例.

polylines = new ArrayList<Polyline>();

protected void onProgressUpdate(PolylineOptions... progress) {
    if (isCancelled()) {
        return;
    }
    if (progress[0] != null) {
        // add the poly line to the map
        // save the polyline for later user
        if (mMap != null) {
            polylines.add(mMap.addPolyline(progress[0]));
        }
    }
}

同时在代码中作用于折线

meanwhile back in the code act on the polyline

polylines.get(0).setWidth(width)

for (Polyline po: polylines){
    po.setWidth(newWidth);
}

这篇关于Android按缩放级别增加折线宽度(Google Maps V2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆