Freeform Drawing with Android Maps v2

后端 未结 1 529
天命终不由人
天命终不由人 2021-01-28 12:43

I have a maps application using the new v2 Google Maps API for Android. What I am trying to do is allow the user to draw a line on the map that follows the path of their finger

1条回答
  •  南方客
    南方客 (楼主)
    2021-01-28 13:29

    I think you could achieve this by using a framelayout that overlays a view above the map fragment. Listen for touch events on that view and set it's visibility to GONE once the user wants to disable the drawing so it wont fire your touch listeners and instead fire the maps ones.

    An alternative would be to use a marker instead of allowing freeform drawing, you can easily listen for marker drag events and draw lines when the drag events finish.

    Closing the polygon would be as easy as drawing a line from the start to the last line's end.

    This will allow you to raw on the map https://developers.google.com/maps/documentation/android/lines

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