Hi,
I want to show the position of the device without the user having to press the location button. So when the map is loaded, the position will be showed as default. I can achieve this by starting the locationDisplay, but the view isn't 'zoomed' to the location. When i use the LocationDisplayAutoPanModeRecenter, the map jumps back and forth before zooming to the position. Is there a solution to this?
mapView.locationDisplay.start(); mapView.locationDisplay.autoPanMode = Enums.LocationDisplayAutoPanModeRecenter; mapView.locationDisplay.initialZoomScale(<scale>);
Try doing it this way Kamran. This should work.
Thanks Kaushik, but the map still jumps back and forth before zooming to the actual location.
Hi Kamaran,
Please try this:
mapView.locationDisplay.autoPanMode = Enums.LocationDisplayAutoPanModeRecenter;
mapView.locationDisplay.start();
I have created a simple app to test the auto zoom to device location function, it works fine. Please see the code below.
import QtQuick 2.7
import QtQuick.Controls 2.1
import QtPositioning 5.3
import QtSensors 5.3
import ArcGIS.AppFramework 1.0
import ArcGIS.AppFramework.Controls 1.0
import Esri.ArcGISRuntime 100.1
App {
id: app
width: 400
height: 640
MapView {
id: mapView
anchors.fill: parent
Map {
BasemapImagery {}
// start the location display
onLoadStatusChanged: {
if (loadStatus === Enums.LoadStatusLoaded) {
mapView.locationDisplay.autoPanMode = Enums.LocationDisplayAutoPanModeRecenter;
mapView.locationDisplay.start();
}
}
}
// set the location display's position source
locationDisplay {
positionSource: PositionSource {
}
compass: Compass {}
}
}
}