Erhalte diesen Fehler, wenn du einen Ort auf der Karte suchen willst. Andere Lösungen bei der Suche versucht, aber kein Glück. java.lang.IllegalStateException: keine enthaltenen Punkte in dieser Zeile: LatLngBounds.Builder builder = new LatLngBounds.Builder(); Code verwende ich:java.lang.IllegalStateException: keine Punkte enthalten?
try {
JSONObject jsonObject = new JSONObject(response.body().toString());
JSONArray jsonArray = jsonObject.getJSONArray("routes");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject route = jsonArray.getJSONObject(i);
JSONObject poly = route.getJSONObject("overview_polyline");
String polyline = poly.getString("points");
polyLineList = decodePoly(polyline);
}
// Adjusting Bounds
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (LatLng latLng:polyLineList) {
builder = builder.include(latLng);
}
LatLngBounds bounds = builder.build();
CameraUpdate mCameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, 2);
mMap.animateCamera(mCameraUpdate);
private List decodePoly(String encoded) {
List poly = new ArrayList();
int index = 0, len = encoded.length();
int lat = 0, lng = 0;
while (index < len) {
int b, shift = 0, result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lng += dlng;
LatLng p = new LatLng((((double) lat/1E5)), (((double) lng/1E5)));
poly.add(p);
}
return poly;
}
Jede Hilfe willkommen wäre stark
Ich denke, das könnte ein Duplikat von [Android Google V2 MarkerDemo Illegal keine eingeschlossenen Punkte] sein (https://stackoverflow.com/questions/14878077/android -googlemaps-v2-markerdemo-illegalstateexception-no-included-punkte) –
Ich habe mir das angesehen und bin immer noch nicht in der Lage, das zu beheben. Wie kann ich dies in den von mir bereitgestellten Code implementieren? Dies ist ein Tutorial, das ich mache. – LizG