Drag Polyline onMarkerDrag Android Google Maps v2

前端 未结 1 1644
广开言路
广开言路 2021-01-22 05:30

I\'m currently developing an android application that would allow users to draw Polylines with Markers on the map. Right now, I would like to implement a feature whereby the pol

相关标签:
1条回答
  • 2021-01-22 06:06

    At first make Polyline drawRoute a field instead of a local variable. Then you can update the polyline inside onMarkerDragEnd by calling drawRoute.setPoints(arrayPoints).

    Then you need in addition a Java-Map, which keeps track of which marker was responsible for which point in the array. The map would have the marker-ID as key and the array-index as value. (You get the marker ID from the marker which is returned by map.addMarker) When a marker is dragged, you can find out the index of the corresponding Point in arrayPoints using the marker-ID and said Java-Map. With that, you can exchange the point in the array and call drawRoute.setPoints again.

    0 讨论(0)
提交回复
热议问题