Android increase polyline width by zoom level (Google Maps V2)

落爺英雄遲暮 提交于 2019-12-08 06:43:13

问题


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.


回答1:


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

Example for saving the polyline to an arraylist when added to the 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]));
        }
    }
}

meanwhile back in the code act on the polyline

polylines.get(0).setWidth(width)

or

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


来源:https://stackoverflow.com/questions/25772999/android-increase-polyline-width-by-zoom-level-google-maps-v2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!