Reputation: 1053
I am trying to find out how to edit polygon by dragging its vertices. There are draggable/editable properties for polygon in the JavaScript API
.
But how can I implement same functionality for android API
?
Upvotes: 2
Views: 1595
Reputation: 1053
I solved this. I add markers for each vertex, save it to list and add onDragListener. Every time when onMarkerDrag callback occurs, i get latLng from markers and set them to polygon.
@Override
public void onMarkerDrag(Marker marker) {
if (mPolygon == null) {
return;
}
mPolygon.setPoints(markersToLatLng(mVertexMarkers));
}
private List<LatLng> markersToLatLng(List<Marker> markers) {
List<LatLng> latLngs = new ArrayList<>();
if (markers == null) {
return latLngs;
}
for (Marker m : markers) {
latLngs.add(m.getPosition());
}
return latLngs;
}
Upvotes: 3