项目作者: seatcode

项目描述 :
iOS: Drawing curvy routes with MapKit
高级语言: Swift
项目地址: git://github.com/seatcode/curvyRoute.git
创建时间: 2019-09-30T12:20:54Z
项目社区:https://github.com/seatcode/curvyRoute

开源协议:MIT License

下载


PRs Welcome
Version
iOS 8.0+

🗺 curvyRoute

An easy way to draw a curvy line between two points on a map.

🏆 Features

  • Display a curve on a map
  • Display a straight line on a map
  • Customise the radius multiplier

📝 Requirements

  • iOS 8.0+
  • Swift 4.2+

🛠 Installation

There are several methods to install curvyRoute:

CocoaPods

Add curvyRoute specs to your Podfile:

  1. pod 'curvyRoute'

👉🏼 Example

  1. import MapKit
  2. import UIKit
  3. import curvyRoute
  4. class ViewController: UIViewController, MKMapViewDelegate {
  5. @IBOutlet weak var mapView: MKMapView!
  6. override func viewDidAppear(_: Bool) {
  7. mapView.delegate = self
  8. addOverlays()
  9. }
  10. func mapView(_: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
  11. if let lineOverlay = overlay as? LineOverlay {
  12. return MapLineOverlayRenderer(lineOverlay)
  13. }
  14. return MKOverlayRenderer(overlay: overlay)
  15. }
  16. private func addOverlays() {
  17. let pointA = CLLocationCoordinate2DMake(41.375024, 2.149118) // Plaça d'Espanya, Barcelona
  18. let pointB = CLLocationCoordinate2DMake(41.380994, 2.185771) // Plaça Pau Vila, 1, Barcelona
  19. mapView.addOverlay(LineOverlay(origin: pointA, destination: pointB))
  20. let arc = ArcOverlay(origin: pointA, destination: pointB,
  21. style: LineOverlayStyle(strokeColor: .systemTeal, lineWidth: 4, alpha: 1))
  22. arc.radiusMultiplier = 0.5
  23. mapView.addOverlay(arc)
  24. }
  25. }

🤔 What is radiusMultiplier ?

This property will influence the shape of the arc. The default value is 1.

👨‍💻 Todo

  • Animate the polyline

📖 License

curvyRoute is released under the MIT license. See LICENSE for details.