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.
Set AGSLocationDisplay.autoPanMode to .navigation.
The location display can be found at AGSMapView.locationDisplay.
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
}
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, <A href="https://developers.arcgis.com/ios/latest/api-reference/interface_a_g_s_c_l_location_data_source.html" style="color: #7a6045; font-weight: bold;" title="A datasource for AGSLocationDisplay based on Core Location. " rel="nofollow noopener noreferrer">AGSCLLocationDataSource</A>, 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.
<A href="https://developers.arcgis.com/ios/latest/api-reference/interface_a_g_s_c_l_location_data_source.html" style="color: #7a6045; font-weight: bold;" title="A datasource for AGSLocationDisplay based on Core Location. " rel="nofollow noopener noreferrer">AGSCLLocationDataSource</A>
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
See also the Display Location sample.
Yes
I am using this code in our application..
please check this code.
//Set up location listener and show user's location on map
locationDisplay.start { (error:Error?) -> Void in
if let error = error {
debugPrint(error.localizedDescription)
self.locationDisplay.locationChangedHandler = self.locationChanged
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?
We 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.
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<SPAN class="punctuation token">.</SPAN>autoPanModeChangedHandler <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="punctuation token">[</SPAN>weak self<SPAN class="punctuation token">]</SPAN> newMode <SPAN class="keyword token">in</SPAN> <SPAN class="keyword token">if</SPAN> newMode <SPAN class="operator token">==</SPAN> <SPAN class="punctuation token">.</SPAN>off <SPAN class="punctuation token">{</SPAN> DispatchQueue<SPAN class="punctuation token">.</SPAN>main<SPAN class="punctuation token">.</SPAN><SPAN class="token function">asyncAfter</SPAN><SPAN class="punctuation token">(</SPAN>deadline<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="token function">now</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN> execute<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN> self<SPAN class="operator token">?</SPAN><SPAN class="punctuation token">.</SPAN>mapView<SPAN class="punctuation token">.</SPAN>locationDisplay<SPAN class="punctuation token">.</SPAN>autoPanMode <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">.</SPAN>navigation <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Or you could just set the interactionOptions appropriately:
mapView<SPAN class="punctuation token">.</SPAN>interactionOptions<SPAN class="punctuation token">.</SPAN>isPanEnabled <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">false</SPAN> mapView<SPAN class="punctuation token">.</SPAN>interactionOptions<SPAN class="punctuation token">.</SPAN>isRotateEnabled <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN></SPAN>
Again, which option you pick depends on the UX you want for your app.
Hope that helps.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.