0

我正在尝试在 google map 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));
    }

}

有人可以在这个问题上帮助我吗?提前致谢

4

1 回答 1

0

我使用折线而不是多边形解决了它

 myMap.addPolyline(new PolylineOptions()
        .addAll(lineCordinates)
        .width(5)
        .color(Color.RED));
于 2013-08-18T10:38:16.890 回答