Im trying using Mapbox iOS8 Swift cocoa plugin for mapbox and facing an issue when trying to show the users location on a mapView. My code is the following
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.
}
I've made the necessary changes to info.pList and get the appropriate message the first time i fire up my app. The issue is, it prints the following:
<MGLUserLocation: 0x7fd8aa6c9a00>
3.40282346638529e+38
3.40282346638529e+38
Can anyone provide me an example of how I can show the users location (blue dot) on the map.
Thanks for giving me a starting point.
I used your code and added the userLocation to my map and it is showing up for me.
Note that I had to plug in my iPhone and run it from there. Don't know if it's supposed to work in the simulator.