In drawing application we can identify when the user is starting to draw and moving the finger to make a line/shape. I'm trying to do the same on a map, how can I do this?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
Map Kit Polyline or Polygon Drawing - https://github.com/tazihosniomar/MapKitDrawing
This link contains demo project for drawing polygons on Apple Map. But, logic remains the same for Google Map View. So, you can copy implementation logic from this and apply it on Google Map.
I hope this will help you.
Basic steps will involve:
1)Add a overlay view whenever user starts to draw.
2)Do free hand drawing in the overlay view.
3)Get all coordinates in an array from OverlayView to Controller using delegate pattern
4)Change that coordinates into a polygon.
I have created a demo project for drawing/deleting multiple polygons on Google Map in Swift 3 here.
Remember setting API key in AppDelegate and changing bundle identifier in order to run the project.
To draw a line use
polyline
. Refer to Google Maps Shapes.To use
polyline
you need to give locatoin coordinates. To convert a point on screen to coordinate usecoordinateForPoint:(CGPoint)point
method of GMSProjection class.Polyline
actually draws a line between two coordinates. Thus, with moving mapView those lines will move, too. I think this is what you want.