MapDoodle 0.0.2

MapDoodle 0.0.2

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布上次发布2016年8月
SPM支持 SPM

Vorn Mom 维护。



MapDoodle 0.0.2

  • Vorn Mom

MapDoodle

Screenshots

为 MapKit 和其他地图提供者创建常用地图动画的 iOS 库。注意,正在开发中。

毫不掩饰的宣传:这个库是为了我的滑雪和单板滑雪应用程序 Mogul Bunny 而编写的。

示例

要运行示例项目,首先从仓库中克隆,然后在 Example 目录中运行 pod install

要求

安装

MapDoodle 可以通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中:

pod "MapDoodle"

基本用法

一旦您获取到一个 MKMapView 实例,只需将其传递给 MapDoodler 的一个实例。然后,将您的航点添加到一个 GeoPath 中。

class ViewController: UIViewController {
  @IBOutlet var mapView: MKMapView!
  var mapDoodler: MapDoodler!

  override func viewDidLoad() {
    super.viewDidLoad()

    mapDoodler = MapDoodler(mapView: mapView, refreshRate: 500)

    let pathDoodleStyle = AnimatedPathDoodleStyle()
    pathDoodleStyle.thickness = 10
    pathDoodleStyle.color = UIColor.blueColor()
    pathDoodleStyle.tracerThickness = 5.0
    pathDoodleStyle.tracerColor = UIColor.grayColor()
    pathDoodleStyle.speed = 250.0

    // Shining Sea Bikeway
    let shiningSeaBikewayPoints: [GeoPoint] = [
      GeoPoint(latitude: 41.551490, longitude: -70.627179),
      GeoPoint(latitude: 41.550410, longitude: -70.627761),
      GeoPoint(latitude: 41.534456, longitude: -70.641752),
      GeoPoint(latitude: 41.534319, longitude: -70.642047),
      GeoPoint(latitude: 41.534032, longitude: -70.642455),
      GeoPoint(latitude: 41.531242, longitude: -70.645581),
      GeoPoint(latitude: 41.524383, longitude: -70.653310),
      GeoPoint(latitude: 41.524383, longitude: -70.653310)
    ]

    let shiningSeaBikewayDoodle = mapDoodler.addAnimatedPathDoodle(pathDoodleStyle, points: shiningSeaBikewayPoints)
    mapDoodler.zoomFitAllDoodles(150, shouldAnimate: false)
  }
}

也可以添加静态(非动态)路径涂鸦。

let pathDoodleStyle = PathDoodleStyle()
pathDoodleStyle.thickness = 10
pathDoodleStyle.color = UIColor.blueColor()

let shiningSeaBikewayPoints: [GeoPoint] = [
// ...
]

let shiningSeaBikewayDoodle = mapDoodler.addPathDoodle(pathDoodleStyle, points: shiningSeaBikewayPoints)

可以在任何时候添加涂鸦(例如,通过用户交互)。

以下支持涂鸦管理

let mapDoodler = MapDoodler(mapView: mapView, refreshRate: 500)
// Add a new doodle.
let doodle = mapDoodler.addPathDoodle(style: pathDoodleStyle, points: points)
// Assign a string ID to a doodle.
doodle.id = "foo"
// Later, you can retrieve the doodle by ID.
let doodle = mapDoodler.getDoodleById(id: "foo")
// Remove a doodle from the map
mapDoodler.removeDoodle(doodle)
// Zoom to fit a doodle.
mapDoodler.zoomToFitDoodle(doodle)
// Zoom to fit all doodles on the map.
mapDoodler.zoomToFitAllDoodles()
// Change the style of a doodle. Style must be for the correct doodle type, otherwise no-op.
doodle.setStyle(style: newStyle)

作者

Vorn Mom, [email protected]

许可证

MapDoodle 在 MIT 许可证下提供。请参阅 LICENSE 文件以获取更多信息。