【发布时间】:2015-06-18 11:43:34
【问题描述】:
我正在尝试使用 Mapbox iOS8 Swift cocoa 插件用于 mapbox,并在尝试在 mapView 上显示用户位置时遇到问题。我的代码如下
func mapView(mapView: MGLMapView!, symbolNameForAnnotation annotation: MGLAnnotation!) -> String! {
return "secondary_marker"
}
let manager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
let mapView = MGLMapView(frame: view.bounds, accessToken: "pk.privateMapboxAccessTokenGoesHere")
mapView.autoresizingMask = .FlexibleWidth | .FlexibleHeight
if CLLocationManager.authorizationStatus() == .NotDetermined {
manager.requestAlwaysAuthorization()
}
mapView.showsUserLocation = true
let x:MGLUserLocation = mapView.userLocation
println(mapView.userLocation)
println(x.coordinate.latitude)
println(x.coordinate.longitude)
... more code here to show map works.
}
我已经对 info.pList 进行了必要的更改,并在我第一次启动我的应用程序时收到了相应的消息。问题是,它会打印以下内容:
<MGLUserLocation: 0x7fd8aa6c9a00>
3.40282346638529e+38
3.40282346638529e+38
谁能提供我如何在地图上显示用户位置(蓝点)的示例。
【问题讨论】:
标签: ios swift cllocationmanager mapbox