2

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?

1 Answer 1

3

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;
}
Sign up to request clarification or add additional context in comments.

1 Comment

stackoverflow.com/questions/61527262/… please see this question. i also have the same problem i use this code

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.