Android-MapView响应缓慢

时间:2018-10-05 05:31:39

标签: java android android-mapview polyline

带有多段线的MapView在拖动和缩小时响应时间很短。我不知道如何调试此错误。有谁可以帮助我吗。这是调用和显示折线时的代码。

这是代码:

for (int i = 0; i < arrayOfPoly.size(); i++) {
 map.getOverlays().addAll(arrayOfPoly.get(i));
}

来自此方法:

 public void plotFacilitiesToMap(){

    final ProgressDialog progressDialog;
    progressDialog = new ProgressDialog(MapActivity.this);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setTitle("Please Wait");
    progressDialog.setMessage("Map loading....");
    progressDialog.show();

    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {

        @Override
        public void run() {
        Thread thread = new Thread(){
            public void run(){
                try{
                    arrayOfMarkers = arrayOfMarkerArray(Geopoints("POINT"));
                    arrayOfPoly = arrayOfPolyLineArray(LineGeometry("LINESTRING"));
                    for (int i = 0; i < arrayOfMarkers.size(); i++){
                        map.getOverlays().addAll(arrayOfMarkers.get(i));
                    }
                    for (int i = 0; i < arrayOfPoly.size(); i++) {
                        map.getOverlays().addAll(arrayOfPoly.get(i));
                    }

                }finally{
                    progressDialog.dismiss();
                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                         map.invalidate();
                        }
                    });
                }
            }
        };
        thread.start();
        }
    }, 500);
}

0 个答案:

没有答案