java 如何在android谷歌地图版本2中的2个地理点之间画线?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16631175/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to draw line between 2 Geo points in android Google maps version 2?
提问by katra
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?
如何在 Google 地图版本 2 中绘制一个地理点与另一个地理点之间的线?
我知道这里有一些公认的答案。根据这些答案,我必须覆盖 draw() 函数。但是我使用片段来显示谷歌地图。所以我无法从我的活动中覆盖该功能。
谁能帮我吗?
回答by CommonsWare
How can I draw the line between one Geo point to another in Google maps version 2?
如何在 Google 地图版本 2 中绘制一个地理点与另一个地理点之间的线?
GeoPoint
is only for Maps V1. To draw lines in Maps V2, you would add a Polylineto your GoogleMap
:
GeoPoint
仅适用于地图 V1。要绘制在地图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)