I made a map view with GMSMapView and I wanted to draw a polyline according to the touch of a finger. but this feature makes me stuck because I have not been able to find the appropriate reference.
in my case example like the result domain app that I want.
Thank you for your help.
This is a pretty big, complicated question, so I will outline steps for you to follow to implement this. If you need help with a specific step, I suggest you post a separate, specific question.
Here we go:
When the "draw mode" button is tapped, add a view above the map
Subclass this view and override touchesBegan
and touchesMoved
to actually do the drawing. You can follow the tutorial here for that.
Keep an array of all vertices of the polygon in the view's coordinate system.
touchesEnded
(when the user stops drawing), convert the points from above to map coordinates.
If you need clarification about this process don't hesitate to ask.
You should draw the lines using Quartz2D since this question is kind of large i'll just point you to a good reference.
https://www.raywenderlich.com/87899/make-simple-drawing-app-uikit-swift
here you should be able to figure out how to draw to the screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With