Route always face up

779
7
05-15-2019 06:14 AM
tejveer
New Contributor

Set path mode:

The direction that the user should be moving should be facing upward. This is similar to the way that driving apps do it. The map moves as the user moves along the route.

Tags (1)
0 Kudos
7 Replies
Nicholas-Furness
Esri Regular Contributor

Set AGSLocationDisplay.autoPanMode to .navigation.

The location display can be found at AGSMapView.locationDisplay.

0 Kudos
tejveer
New Contributor

Hi Nicholas Furness 

I have set AGSLocationDisplay.autoPanMode to .navigation but not map moving according to user moved. i have used code given below.

please help me any suggestion. Thanks in advance.

override func viewDidLoad() {

        super.viewDidLoad()

         locationDisplay = self.mapView.locationDisplay

        locationDisplay.autoPanMode = AGSLocationDisplayAutoPanMode.navigation

        locationDisplay.navigationPointHeightFactor = 0.5

        locationDisplay.showAccuracy = true

}

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Are you starting the location display with AGSLocationDisplay.start(completionHandler)?

Be sure to check for an error in the completionHandler. Note that Apple insist you provide certain keys in your info.plist if you wish to use location. See the note here: ArcGIS Runtime SDK for iOS: AGSLocationDisplay Class Reference 

The default location datasource, AGSCLLocationDataSource, needs the app to be authorized in order to access the device's location. The app's Info.plist must contain appropriate purpose strings (NSLocationWhenInUseUsageDescription, NSLocationAlwaysUsageDescription, or NSLocationAlwaysAndWhenInUseUsageDescription keys) to permit this functionality. When the datasource is started it will attempt to request when-in-use authorization if the app's authorization status is not determined, otherwise it will reuse the authorization that has already been granted. If authorization is denied, location updates will not be available.

See also the Display Location sample.

0 Kudos
tejveer
New Contributor

Yes 

Are you starting the location display with AGSLocationDisplay.start(completionHandler)?

I am using this code in our application..

please check this code. 

//Set up location listener and show user's location on map

        locationDisplay = self.mapView.locationDisplay

        locationDisplay.autoPanMode = AGSLocationDisplayAutoPanMode.navigation

        locationDisplay.navigationPointHeightFactor = 0.5

        locationDisplay.showAccuracy = true

 

        locationDisplay.start { (error:Error?) -> Void in

            if let error = error {

                debugPrint(error.localizedDescription)

            }

            self.locationDisplay.locationChangedHandler = self.locationChanged

        }

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Could you provide more details please?

You're seeing the blue dot on the map, and you see the dot moving, but the map isn't orienting itself properly? Perhaps a video or a screenshot would help.

What version of Runtime are you using?

0 Kudos
tejveer
New Contributor

W

e are able to seen blue dot as well as moving on the map but not moving map automatically during user navigate. and i have shared video with code snippet given below.please help me. thanks in advance.

override func viewDidLoad() {

        super.viewDidLoad() 

         locationDisplay = self.mapView.locationDisplay

        locationDisplay.autoPanMode = AGSLocationDisplayAutoPanMode.navigation

        locationDisplay.navigationPointHeightFactor = 0.5

        locationDisplay.showAccuracy = true

       locationDisplay.start { (error:Error?) -> Void in

            if let error = error {

                debugPrint(error.localizedDescription)

            }

            self.locationDisplay.locationChangedHandler = self.locationChanged

        }

}

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Ah. It looks like you're interacting with the map view. When you do that, the autoPan mode is reset to .off.

You could use the autoPanModeChangeHandler to detect when that happens and either enable a button in your UI (remember to dispatch to main, since the handler could be invoked on any thread), or you could switch the autoPan mode back again (perhaps after a delay). You'll need to think what you want your UX to be.

locationDisplay.autoPanModeChangedHandler = { [weak self] newMode in
    if newMode == .off {
        DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
            self?.mapView.locationDisplay.autoPanMode = .navigation
        })
    }
}
‍‍‍‍‍‍‍

Or you could just set the interactionOptions appropriately:

mapView.interactionOptions.isPanEnabled = false
mapView.interactionOptions.isRotateEnabled = false‍‍

Again, which option you pick depends on the UX you want for your app.

Hope that helps.

0 Kudos