2016-04-20 129 views
1

我想用最新的MapBox iOS idk(3.2)安装iOS应用程序。我在网上寻找多少钱,我找不到一个如何将地图事件添加到地图视图的示例。MapBox iOS SDK:添加地图事件

例如:我想在地图变得空闲时添加一个事件。有什么建议么?

UPDATE

我想,这是实现正确的方法:

func mapView(mapView: MGLMapView, regionDidChangeAnimated animated: Bool) { 


} 

回答

2

如果你问如何使用委托方法,方法如下:

import Mapbox 

// Declare conformance to the MGLMapViewDelegate protocol 
class ViewController: UIViewController, MGLMapViewDelegate { 

    var mapView: MGLMapView! 

    override func viewDidLoad() { 
     super.viewDidLoad() 

     mapView = MGLMapView(frame: view.bounds) 
     mapView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight] 
     view.addSubview(mapView) 

     // Set the delegate property of our map view to self after instantiating it. 
     mapView.delegate = self 
    } 

    func mapView(mapView: MGLMapView, regionDidChangeAnimated animated: Bool) -> Bool { 
     // look at mapView properties and do something 
    } 
} 

https://www.mapbox.com/ios-sdk/examples/为如何使用Mapbox iOS SDK实现基本功能的示例。