Drawing Freeform with Android Maps v2

I have a map application using the new Google Maps API for Android. What I'm trying to do is let the user draw a line on the map that follows the path of their finger. I understand that I will probably need a button to turn this feature on / off, since it clearly needs to turn off the pan / zoom controls. When the user draws his line, I need to be able to join the ends to form a polygon. Does anyone know how to do this? Read any help!

0
android google-maps-android-api-2
Feb 10
source share
1 answer

I think you could achieve this using a framelayout that overlays the view over the map fragment. Listen to the touch events on this screen and set its visibility to GONE as soon as the user wants to turn off the drawing so that he does not start your touch listeners and instead launches maps.

An alternative would be to use a marker instead of allowing arbitrary shape drawing, you can easily listen to marker drag events and draw lines when drag events end.

Closing the polygon will be as simple as drawing a line from the beginning to the end of the last line.

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

0
Feb 10 '13 at 14:14
source share



All Articles