简体   繁体   English

如何在Android谷歌地图版本2中的2个地理点之间画线?

[英]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? 如何在Google地图版本2中绘制一个Geo点到另一个点之间的界限?
I know some accepted answers are available here. 我知道这里有一些可接受的答案。 According to those answers I have to override draw() function. 根据那些答案,我必须覆盖draw()函数。 But I Used fragments for displaying Google maps. 但我使用片段显示谷歌地图。 so I can not override that function from my activity. 所以我无法从我的活动中覆盖该功能。
Can any one help me out? 谁能帮我吗?

How can I draw the line between one Geo point to another in Google maps version 2? 如何在Google地图版本2中绘制一个Geo点到另一个点之间的界限?

GeoPoint is only for Maps V1. GeoPoint仅适用于Maps V1。 To draw lines in Maps V2, you would add a Polyline to your GoogleMap : 要绘制在地图V2线,你会添加一个折线到您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 ) (来自此示例应用程序 ,在本书中有详细描述)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM