0
我試圖通過谷歌地圖v2繪製一個自由形式的線條,所以我試圖通過聽標記拖動來做到這一點。我寫了下面的代碼,但它沒有畫任何東西使用onMarkerDrag繪製多邊形谷歌地圖v2
@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));
}
}
任何人都可以幫助我解決這個問題嗎?在此先感謝