Closed lillapulay-esri closed 1 day ago
The original code for obtaining latitude and longitude is fine, x and y are just screen coordinates; you can check if the point is right. https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#properties-summary
@blissvisitor Thank you for your answer!
For me the latitude
and longitude
of the point (and of jmv.view.center
) is always null
, only x
an y
have non-null values. I think since setLatitude
and setLongitude
use latitude
and longitude
instead of x
and y
, these will always have a null value.
According to the link you sent, which of these values can be used depends on the spatial reference - I'm new to this topic, so the only thing I did was following the tutorial, but just with those steps alone I can't get this to work, unless I change the code the way I did in this PR (plus, as I only just noticed, activeViewChangeHandler
should also be edited for the map's extent to be changeable).
So do you mean the code/solution for the above mentioned tutorial works fine for you? For me it just displays that error and the placeholder text next to lat/lon. Please let me know, would like to understand it!
It works fine for me, Please check your environment, note that this widget requires the selection of a Map Widget.
https://github.com/user-attachments/assets/ea104025-ecd1-4c90-983b-f4c88da39cfc
Thank you for your time! I'll close this PR then, and try to figure out why it's not working for me.
The get-map-coordinates tutorial features code snippets in order to display the cursor's coordinates when hovering over the map.
After following the steps, I ran into an error (Uncaught TypeError: Cannot read properties of null (reading 'toFixed')), so the lat/long values couldn't be displayed either. The 'completed widget' solution, that can be downloaded from the tutorial page, features the same code snippet:
The changes in this PR should fix this error by using the correct properties to update the state, so the tutorial's outcome is functional.