2016-04-20 127 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實現基本功能的示例。