Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get map coordinates #176

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

esride-nik
Copy link
Contributor

The "get map coordinates" widget ran into null pointer issues for SRs other than 4326 or 3857. latitude and longitude or map center resp. mouse coordinate are undefined when using a projected coordinate system like 25832 (UTM 32N). First step was to prevent the null pointer errors by adding conditional access (latitude?.toFixed(3)), second step was to project the points if necessary.

@qlqllu
Copy link
Collaborator

qlqllu commented Jan 25, 2024

@esride-nik Thanks for the PR! For the geometry projection, can you try whether this works?

import { geometryUtils } from 'jimu-core'
geometryUtils.projectToSpatialReference()

@grothkha
Copy link

using geometryUtils leads to an error

Uncaught (in promise) TypeError: t.equals is not a function
    at Module.<anonymous> (index.js:2:592375)
    at Generator.next (<anonymous>)
    at index.js:2:591904
    at new Promise (<anonymous>)
    at nC (index.js:2:591649)
    at Module.oC (index.js:2:592270)
    at Widget.<anonymous> (widget.tsx:60:27)
    at Generator.next (<anonymous>)
    at set-public-path.ts:7:52
    at new Promise (<anonymous>)

widget.tsx:60:27 is our function call

geometryUtils.projectToSpatialReference([point], { wkid: 4326 } as __esri.SpatialReference)

while parameter "point" is our esri/geometry/Point in wkid 25832

@esride-nik
Copy link
Contributor Author

Thanks @grothkha! (He's the one with the right service at hand.)
Btw @qlqllu, your documentation doesn't say anything about geometryUtils ;)

@qlqllu
Copy link
Collaborator

qlqllu commented Jan 26, 2024

Could you create a SpatialReference instance? For the documentation, there are still many classes/methods that are not documented yet, we are trying to add more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants