AnsweredAssumed Answered

Can't get user location in iOS app using a web map.

Question asked by gdelarosa on Sep 3, 2016
Latest reply on Sep 12, 2016 by Yue_Wu-esristaff

Im running a web map on my ios app using Swift but am unable to get the current location once the map loads. I've also made sure to add NSLocationWhenInUseUsageDescription in the Info.plist file. Below is the code I'm working with. 


import UIKit

import ArcGIS

import CoreLocation


class MapViewController: UIViewController, AGSCalloutDelegate, AGSMapViewLayerDelegate, AGSWebMapDelegate, CLLocationManagerDelegate



   @IBOutlet weak var mapView: AGSMapView!


    let webMap = AGSWebMap(itemId: "f553d4b86e354c05917ad269de26f6f0", credential: nil) 

    var locationManager = CLLocationManager()


override func viewDidLoad() {




        self.webMap.delegate = self


        locationManager = CLLocationManager()

        locationManager.delegate = self

        locationManager.desiredAccuracy = kCLLocationAccuracyBest






    func webMapViewDidLoad(mapView: AGSWebMap!) {



    func webMapDidLoad(webMap: AGSWebMap!) {

        print("Web Map Loaded")   


    func didOpenWebMap(webMap: AGSWebMap!, intoMapView mapView: AGSMapView!) {

        print("Opened the Web Map into the Map View")


    func webMap(webMap: AGSWebMap!, didLoadLayer layer: AGSLayer!) {

        print("Loaded layer \(")


    func webMapView(webMap: AGSWebMap!, didFailToLoadWithError error: NSError!) {

        print("Layer failed to load into Web Map! \(error.localizedDescription)")






Any help would be greatly appreciated!