katra
katra

Reputation: 121

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?

Upvotes: 7

Views: 12818

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006704

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)

Upvotes: 29

Related Questions