Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to draw line between 2 Geo points in android Google maps version 2?

How can I draw the line between one Geo point to another in Google maps version 2?
I know some accepted answers are available here. According to those answers I have to override draw() function. But I Used fragments for displaying Google maps. so I can not override that function from my activity.
Can any one help me out?

like image 433
katra Avatar asked May 19 '13 03:05

katra


1 Answers

How can I draw the line between one Geo point to another in Google maps version 2?

GeoPoint is only for Maps V1. To draw lines in Maps V2, you would add a Polyline to your GoogleMap:

  PolylineOptions line=
      new PolylineOptions().add(new LatLng(40.70686417491799,
                                           -74.01572942733765),
                                new LatLng(40.76866299974387,
                                           -73.98268461227417),
                                new LatLng(40.765136435316755,
                                           -73.97989511489868),
                                new LatLng(40.748963847316034,
                                           -73.96807193756104))
                           .width(5).color(Color.RED);

  map.addPolyline(line);

(from this sample app, described in detail in this book)

like image 72
CommonsWare Avatar answered Nov 15 '22 07:11

CommonsWare