Skip to content Skip to sidebar Skip to footer

Drag Polyline Onmarkerdrag Android Google Maps V2

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 polylin

Solution 1:

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.

Post a Comment for "Drag Polyline Onmarkerdrag Android Google Maps V2"