0

i'm doing an app in android studio and what i'm trying to do is a route tracking app, the user touch a play button and he can see in the map a marker with his route being drawn by polylines.

I did that already but i want your help because when the user touch the stop button i want to take a Snapshot of the complete route (including the start point and the end point) and i don't know how to do that, because if the route is long and the zoom is close to the map then the starting point isn't going to show...

I hope you understand and could help me! :)

Rocketron
  • 3
  • 3

1 Answers1

0

Sorry for my English, I use this example in my code to zoom all the markers, its simple i use a cycle for add the LatLng and zoom all.. with CameraUpdateFactory.newLatLngBounds(bounds_latandlog,padding);, and you take the Snapshot...

LatLngBounds.Builder builder = new LatLngBounds.Builder();

///this is an example
LatLng latLng;// create var LatLng
for(int i=0;i<=10;i++)// you will do a type of cycle, tu add lat and long
{
    latLng = new LatLng(lat, lon);// in this line put you lat and long 
    builder.include(latLng);  //add latlng to builder
}


//create a lat long bounds 
LatLngBounds bounds = builder.build();

//create a padding of the points and the camera of the map
int padding = 0; // offset from edges of the map in pixels
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);

//finally move the camera, to zoom all the polylines

/// move the camera
googleMap.moveCamera(cu);
//or animate the camera...
googleMap.animateCamera(cu);

This is the link, for more information

Android map v2 zoom to show all the markers

if you see some error, or you have a better syntaxis, please explane me, I want to learn it.

Community
  • 1
  • 1
DarckBlezzer
  • 4,578
  • 1
  • 41
  • 51