swift - Can't display user current location Mapbox iOS API -


i want display user's current location after open app. use mapbox ios sdk. doesn't work @ all. don't know what's wrong. can see irrelevant map after open it.

import uikit import mapbox import corelocation  class viewcontroller: uiviewcontroller, mglmapviewdelegate, cllocationmanagerdelegate  {  @iboutlet weak var mapview: mglmapview!   let locationmanager = cllocationmanager()  override func viewdidload() {     super.viewdidload()     self.locationmanager.delegate = self     self.locationmanager.desiredaccuracy = kcllocationaccuracybest     self.locationmanager.requestwheninuseauthorization()     self.locationmanager.startupdatinglocation()    }   override func didreceivememorywarning() {     super.didreceivememorywarning()     // dispose of resources can recreated. }  // mark: location delegate methods   func locationmanager(manager: cllocationmanager, didupdatelocations locations: [cllocation])  {     let location = locations.last     let mapview = mglmapview(frame: view.bounds)     mapview.usertrackingmode = .follow     let center = cllocationcoordinate2d(latitude: location!.coordinate.latitude, longitude: location!.coordinate.longitude)     mapview.setcentercoordinate(center, zoomlevel: 15, animated: true)     view.addsubview(mapview)     self.locationmanager.stopupdatinglocation() } func  locationmanager(manager: cllocationmanager, didfailwitherror error: nserror) {     print ("errors:" + error.localizeddescription) }    } 

i think issue might ios simulator. when run app on simulator, doesn't simulate location until tell to. if @ xcode, you'll see navigate button @ bottom.

enter image description here

try changing location something, , should show :)


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -