Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Android API v2 Route Overlay

Playing around with the new API today to see if I can port my current app to it, I see that there is no MapView.getOverlays().add(...); Conceptually, it seems hard to imagine how an overlay which was previously 2D, would be rearranged when the map is tilted.

I see that there is functionality for something called GroundOverlay but this does not look applicable to my case. I also see Polyline and this looks better suited to my purpose.

Does anyone have any idea on how, or if one will be able to add a route overlay (I'm using the Directions API) using the mapping API v2?

like image 441
qubz Avatar asked Dec 04 '12 09:12

qubz


1 Answers

It's done with Polyline. From the example on the Google Developers page - https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/Polyline

GoogleMap map;
   // ... get a map.
   // Add a thin red line from London to New York.
   Polyline line = map.addPolyline(new PolylineOptions()
       .add(new LatLng(51.5, -0.1), new LatLng(40.7, -74.0))
       .width(5)
       .color(Color.RED));
like image 80
qubz Avatar answered Sep 19 '22 13:09

qubz