Google Maps user-editable polygon with fixed number of points in Android?

前端 未结 2 2065
攒了一身酷
攒了一身酷 2020-12-21 17:20

I am working on Google Map polygon marker, I have predefined lat/long array, and need to set polygon area, It is working fine for me, but when I drag the marker polygon line

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-21 18:02

    I think you're using the tools you have a little inefficiently. My recommendation would be to store an array of markers, and use markerTag to store the index of your point, so in drawPolygon

    for (int i = 0; i < coordinates.size(); i++) {
       markers[i].setTag(i); //Associate a marker with a point
    }
    

    Then, when you move the marker, you would replace the co-ordinate at that point like so:

    points[marker.getTag().toInt()] = marker.getTag().getPosition();
    

    Sorry this is so vague. I use kotlin, so I've probably gotten some of the syntax wrong, too.

提交回复
热议问题