Select to view content in your preferred language

LocationDisplay within MapExtent

739
7
Jump to solution
09-10-2024 04:49 AM
AdrianaPaese
Frequent Contributor

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

0 Kudos
4 Solutions

Accepted Solutions
imbachb
Regular Contributor

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.

View solution in original post

AdrianaPaese
Frequent Contributor

Thank you very much @imbachb, but then I have an additional question: how do I retrieve the Point Geometry (XY coordinates)  from 

var locationDisplay = rememberLocationDisplay()
 
which is where I believe the location is actually being stored
 
Thank you very much again!
 

View solution in original post

0 Kudos
GuntherHeppner
Esri Contributor

@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.

View solution in original post

GuntherHeppner
Esri Contributor

@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.

View solution in original post

7 Replies
imbachb
Regular Contributor

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.

AdrianaPaese
Frequent Contributor

Thank you very much @imbachb, but then I have an additional question: how do I retrieve the Point Geometry (XY coordinates)  from 

var locationDisplay = rememberLocationDisplay()
 
which is where I believe the location is actually being stored
 
Thank you very much again!
 
0 Kudos
GuntherHeppner
Esri Contributor

@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.

GuntherHeppner
Esri Contributor

In addition to @imbachb proposal, you can keep track of the current location of your device by collecting on the LocationDataSource.locationChanged flow.

AdrianaPaese
Frequent Contributor

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

locationDisplay.dataSource.start()
 
we are not actually collecting / storing the user´s location
it is just used for displaying a graphic on the screen and when the user leaves the app it is not maintained on the device.
 
Is my interpretation correct?
 
Thank you very much

 

 

 

0 Kudos
GuntherHeppner
Esri Contributor

@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
Frequent Contributor

Thank you very much

0 Kudos