Hello
I am trying to
setAutoPanMode(LocationDisplayAutoPanMode.Recenter) only when the user is within the ArcGISMap
maxExtent.
If I leave setAutoPanMode(LocationDisplayAutoPanMode.Recenter) in the code and the device is outsite the maxExtent, the MapView is centered on a location that does not make sense.
Does anyone have a hint on how may I place a condition on the setAutoPanMode (if this is the best solution)?
Thank you very much in advance
Solved! Go to Solution.
Not sure if this solves your issue, but you can use the GeometryEngine to check if a geometry contains another geometry, see contains (arcgis.com)
So you should be able to get the mapExtent, which is an Envelope Geometry, and check if it contains the user, which is a Point Geometry.
Thank you very much @imbachb, but then I have an additional question: how do I retrieve the Point Geometry (XY coordinates) from
@AdrianaPaese - correct, "collecting" here is just referring to Kotlin's Flow terminology where location changed events are "emitted" by a flow and "collected" by a user. It does not mean that the location data is stored by the Maps SDK on the device in any way, it is only used for displaying purposes with the LocationDisplay.
@AdrianaPaese - you can retrieve the LocationDisplay.location, either by reading the value of this StateFlow on demand (via LocationDisplay.location.value) or by collecting emitted values from the flow. See my comments below re "collecting" from a flow.
LocationDisplay.location emits Location values and Location.position gives you the actual map point.
Not sure if this solves your issue, but you can use the GeometryEngine to check if a geometry contains another geometry, see contains (arcgis.com)
So you should be able to get the mapExtent, which is an Envelope Geometry, and check if it contains the user, which is a Point Geometry.
Thank you very much @imbachb, but then I have an additional question: how do I retrieve the Point Geometry (XY coordinates) from
@AdrianaPaese - you can retrieve the LocationDisplay.location, either by reading the value of this StateFlow on demand (via LocationDisplay.location.value) or by collecting emitted values from the flow. See my comments below re "collecting" from a flow.
LocationDisplay.location emits Location values and Location.position gives you the actual map point.
In addition to @imbachb proposal, you can keep track of the current location of your device by collecting on the LocationDataSource.locationChanged flow.
Thank you very much @GuntherHeppner
I just would like to pan/zoom to the user´s initial location so that the user knows where he is on the MapView. I was not thinking of collecting the user location as it changes.
However, since you mentioned it and for the purpose of defining Privacy Policies it is my understanding that when we use var locationDisplay = rememberLocationDisplay() or
@AdrianaPaese - correct, "collecting" here is just referring to Kotlin's Flow terminology where location changed events are "emitted" by a flow and "collected" by a user. It does not mean that the location data is stored by the Maps SDK on the device in any way, it is only used for displaying purposes with the LocationDisplay.
Thank you very much