Android 通过缩放级别增加多段线宽度(谷歌地图 V2)

标签 android google-maps-android-api-2 polyline

有什么方法可以在我放大和缩小 Google Maps V2 时自动增加和减少多段线的宽度?

当它仍然非常薄时,它看起来很糟糕,尤其是在较新的设备上。但是当缩小时你需要它那么薄。

最佳答案

添加到 map 时保存折线。然后对折线执行操作。

添加到 map 时将折线保存到数组列表的示例。

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]));
        }
    }
}

同时回到代码中对折线进行操作

polylines.get(0).setWidth(width)

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

关于Android 通过缩放级别增加多段线宽度(谷歌地图 V2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25772999/

相关文章:

android - Fortran 编译器

java - fragment .java 错误 : No suitable method in found and cannot resolve method 'inflate(int, boolean)'

android - 我们如何在android studio中进行post方法调用

android - 相同的 android cmake git 项目在一台 Ubuntu 机器上编译良好但在另一台 Ubuntu 机器上编译不成功,即使整个项目是相同的

android - 方法 getController() 未为类型 MapView 定义

javascript - 如何使用 Javascript 访问现有的传单 map 多段线,然后对其进行动画处理?

android - GooglePlayServicesUtil.getErrorDialog 为空

java - 谷歌地图 : How to restore markers when resuming map activity

javascript - 谷歌地图 API : Setting up callbacks for adding markers/polyline

algorithm - 确定给定折线与一组现有折线的近似重叠