거리별로 총 3단계의 속도를 측정해 구글맵에 속도별 색상을 다르게 하여 그려주는 어플을 만들고있습니다.
짧은 거리에서는 괜찮은데 데이터가 500개만 넘어가도 출력하는데 시간이 너무 오래 걸리네요.
어느부분을 수정해야 좀더 빠르게 출력시킬수 있을까요?
아래 코드를 첨부하였습니다. 답변 부탁드립니다!
mMap.getMap().clear();
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(maxLatLng);
builder.include(minLatLng);
LatLngBounds bounds = builder.build();
LatLng startLatLng = new LatLng(startLat,startLng);
LatLng endLatLng = new LatLng(endLat,endLng);
for (int i = 0; i<pathList.size(); i++) {
if (i > 0) {
switch((int)col[i-1]){
case 0:
Log.i("up test 0", "" + col);
List<LatLng> tempPath;
tempPath = new ArrayList<LatLng>();
tempPath.add(0, pathList.get(i - 1));
tempPath.add(1, pathList.get(i));
mMap.getMap().addPolyline(new PolylineOptions().color(Color.rgb(65, 255, 58)).width(12.0f).addAll(tempPath));
break;
case 1:
Log.i("up test 1", "" + col);
tempPath = new ArrayList<LatLng>();
tempPath.add(0, pathList.get(i - 1));
tempPath.add(1, pathList.get(i));
mMap.getMap().addPolyline(new PolylineOptions().color(Color.rgb(255, 112, 18)).width(12.0f).addAll(tempPath));
break;
case 2:
Log.i("up test 2", "" + col);
tempPath = new ArrayList<LatLng>();
tempPath.add(0, pathList.get(i - 1));
tempPath.add(1, pathList.get(i));
mMap.getMap().addPolyline(new PolylineOptions().color(Color.rgb(255, 18, 18)).width(12.0f).addAll(tempPath));
break;
}
}
}
mMap.getMap().animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 500, 500, 1));
mMap.getMap().addMarker(new MarkerOptions().position(startLatLng).icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_start_point)));
mMap.getMap().addMarker(new MarkerOptions().position(endLatLng).icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_end_point)));