使用onMarkerDrag谷歌地图V2绘制多边形 [英] Draw polygon using onMarkerDrag google map v2
本文介绍了使用onMarkerDrag谷歌地图V2绘制多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想画在谷歌地图V2自由形式的线条,所以我想通过听标记拖动做到这一点。我写了下面code,但它并没有画任何东西。
I'm trying to draw a free form lines over google map v2, so I'm trying to do this by listening to marker drag. I wrote the following code but it doesn't draw anything
@Override
public void onMarkerDrag(Marker marker) {
Integer markerId = markerMapHash.get(marker);
// as I'm giving every marker a key by HashMap
if (markerId == 1) {
System.out.println("this is the draw line marker: "+marker.getPosition());
lineCordinates.add(marker.getPosition());
// lineCordinates is an arrayList
}
for (int i = 0; i < lineCordinates.size(); i++) {
myMap.addPolygon(new PolygonOptions()
.add(lineCordinates.get(i))
.strokeColor(Color.RED));
}
}
任何人都可以帮助我在这个问题?在此先感谢
Could anyone help me in this issue? Thanks in advance
推荐答案
我解决它采用折线代替多边形
I solved it using polyline instead of polygon
myMap.addPolyline(new PolylineOptions()
.addAll(lineCordinates)
.width(5)
.color(Color.RED));
这篇关于使用onMarkerDrag谷歌地图V2绘制多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文