I´ve created a Map Fragment, which adds markers from an arraylist (parsed XML) to a Google map. Between the markers I draw a polyline. All that works fine, but the lines are drawn straight although I´ve activated geodesic.
Is there specific method or code I´ve to implement to get geodesic work. I would like to have a line, which follows the street from on point to another. Or does Geodesic only work with 2 markers? I´ve got more than two.
private void setUpMap() {
PolylineOptions routeDraw = new PolylineOptions().width(5).color(Color.BLUE).geodesic(true);
try {
for (RowItem aPoisMap : poisMap) {
latitude = aPoisMap.getLatitudePoi();
longitude = aPoisMap.getLongitudePoi();
poiTitle = aPoisMap.getTitle();
poiDesc = aPoisMap.getDesc();
marker = mMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title(poiTitle).snippet(poiDesc));
routeDraw.add(new LatLng(latitude, longitude));
}
Polyline polyline = mMap.addPolyline(routeDraw.geodesic(true));
latitudeZoom = poisMap.get(0).getLatitudePoi();
longitudeZoom = poisMap.get(0).getLongitudePoi();
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitudeZoom, longitudeZoom), 14));
mMap.setMyLocationEnabled(true);
} catch (NullPointerException e) {
Context context = getActivity().getApplicationContext();
CharSequence text = getResources().getString(R.string.errormap);
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, text, duration);
toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0);
toast.show();
}
}