有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

绘制多边形线后的java Google地图

我在安卓应用程序中的谷歌地图上删除了几个标记,并在它们之间画了多条线。之后谷歌地图就落后了(滚动不顺畅)。我编写了以下代码来添加标记和绘制线

private void dropPointsOnMyRoot() {
    googleMap.clear();

    LatLng l1 = new LatLng(6.932763, 79.843554);
    LatLng l2 = new LatLng(6.933790, 79.850469);
    LatLng l3 = new LatLng(6.911404, 79.848197);
    LatLng l4 = new LatLng(6.894055, 79.853105);
    LatLng l5 = new LatLng(6.712637, 79.904649);
    LatLng l6 = new LatLng(6.584235, 79.959055);
    LatLng l7 = new LatLng(6.433196, 80.000246);
    LatLng l8 = new LatLng(6.277008, 80.043409);
    LatLng l9 = new LatLng(6.235277, 80.054964);

    LatLng[] locations = {l1, l2, l3, l4, l5, l6, l7, l8, l9};

    LatLng prevLatLng = null;

    for (LatLng location : locations) {
        addMarker(location);

        if(prevLatLng != null){
            //draw line with current latlong
            String url = makeURL(prevLatLng.latitude, prevLatLng.longitude, location.latitude, location.longitude);

            CallURL callURL = new CallURL(url) {

                @Override
                public void result(String res) {
                    drawPath(res);
                }
            };

            callURL.execute("");

            prevLatLng = location;
        }else{
            prevLatLng = location;
        }
    }

    CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(ambalangoda, 10);
    googleMap.animateCamera(cameraUpdate);

}


共 (0) 个答案