我在我的地图上绘制了polyline
,我现在需要向用户显示一些数据。Google map Android API v2 - InfoWindow on polyline?
如何在每个polyline
上绘制文本或InfoWindow?
我添加polyline
喜欢:
ArrayList<LatLng> points = null;
PolylineOptions lineOptions = null;
MarkerOptions markerOptions = new MarkerOptions();
// Traversing through all the routes
for(int i=0;i<result.size();i++){
points = new ArrayList<LatLng>();
lineOptions = new PolylineOptions();
String color = colors[i % colors.length];
// Fetching i-th route
List<HashMap<String, String>> path = result.get(i);
// Fetching all the points in i-th route
for(int j=0;j<path.size();j++){
HashMap<String,String> point = path.get(j);
double lat = Double.parseDouble(point.get("lat"));
double lng = Double.parseDouble(point.get("lng"));
LatLng position = new LatLng(lat, lng);
points.add(position);
}
// Adding all the points in the route to LineOptions
lineOptions.addAll(points);
lineOptions.width(5);
lineOptions.color(Color.parseColor(color));
// Drawing polyline in the Google Map for the i-th route
mMap.addPolyline(lineOptions);
}
例如,我需要这样的:
我并不需要设置标记,我需要像谷歌地图Android的折线设置信息。 –
我明白,但没有一种内置的方式来做到这一点,所以你必须使用其他方法,例如在多段线上创建一个不可见的标记并打开其信息窗口,以便它看起来像打开了一个信息窗口为折线。看到我上面修改的答案。 –
我试过了,但一次只显示一个infoWindow。因为我们需要所有三个infoWindow应该同时打开 – NetDemo