, animateCamera (cu) 예외가 있습니다. 예를 많이 보았고 코드에서 다른 점을 볼 수 없습니다. 누구나 아이디어가 있습니까? 동북 위도/LNG : (43.6026,1.50275) 남서 위도/LNG : (43.5578,1.4243)안드로이드에서 animateCamera 크기가 0 일 수없는 예외 인 경우
LOG : com.google.maps.api
경계는 (디버그에 본)이 값이 .android.lib6.common.apiexception.c : newLatLngBounds (LatLngBounds, int)를 사용하는 동안 오류가 발생했습니다.지도 크기를 0으로 설정할 수 없습니다. 레이아웃이지도보기에 아직 나타나지 않았을 가능성이 큽니다. 레이아웃이 발생할 때까지 기다리거나지도의 크기를 지정할 수있는 newLatLngBounds (LatLngBounds, int, int, int)를 사용하십시오.
{ // Draw Polyline
Double myLat, myLon;
Double myStartLat, myStartLon;
LatLngBounds.Builder builder = new LatLngBounds.Builder();
while (cursor.moveToNext()) {
try {myLat = Double.valueOf(cursor.getString(cursor.getColumnIndexOrThrow(COL_LAT)));}
catch (NumberFormatException e) { myLat=0.0d;}
try {myLon = Double.valueOf(cursor.getString(cursor.getColumnIndexOrThrow(COL_LON)));}
catch (NumberFormatException e) { myLon=0.0d;}
polyline=new LatLng(myLat,myLon);
polylines.add(polyline);
if (cursor.getPosition() == 0) { // start and end of the road
myStartLat=myLat;
myStartLon= myLon;
mapAddMArker(googleMap,polyline,0); // add a marker last arg = 0 = start
}else {
if (cursor.isLast()) { // start and end of the road
mapAddMArker(googleMap, polyline, 9); // add a marker
}
}
builder.include(polyline); // extends bounds to include all the road
}
PolylineOptions poly = new PolylineOptions()
.addAll(polylines)// https://stackoverflow.com/questions/22516015/polyline-not-visible-android-maps-api-v2
.color(Color.RED)
.width(5)
.visible(true)
.zIndex(0); // before = 30
googleMap.addPolyline(poly);
LatLngBounds bounds = builder.build();
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 0); // last argument = padding i
googleMap.animateCamera(cu); // EXCEPTION HERE
// I tried this, it works but it is not what I want to display googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(myStartLat, myStartLon), 15));
}