Select to view content in your preferred language

Get user current view polygon coordinates

1012
4
Jump to solution
03-29-2022 01:50 AM
orahlagi
New Contributor III

Hi, 

i know there is a way to get the user's current mouse coordinates, but i wonder if there is a way to get the user's current view polygon, which means the coordinates of each corner on the map.

The reason behind this, is that i want to show the user points that are only on his current view range, so i need to know which points should i fetch and which not.

Thanks.

1 Solution

Accepted Solutions
collaarwaar
New Contributor

@orahlagi these are 'real' coordinates but in I guess Webmercator-projection (wkid 3857), you want them in geographic coordinates (WGS84 wkid 4326)?

 

In that case there's a geometry-method to reproject webMercatorToGeographic , that might help you?

View solution in original post

4 Replies
orahlagi
New Contributor III

Update: using the watchUtils i can get the 'extent' property which gives me xmin,xmax,ymin,ymax.

I'm not sure how this data can help me to get the real coordinates, maybe someone can shed some light.

0 Kudos
JohnGrayson
Esri Regular Contributor

Depending on how you're going to use it, you should be able to directly use the MapView.extent as the 'search/selecting/etc' geometry.  If you absolutely need the geometry as a Polygon then maybe check out the 'fromExtent()' static method.

orahlagi
New Contributor III

Thanks.

I need the geometry for the server, so i am able to get a polygon from the extent, and i'm getting "rings" array which are the xmin,ymax etc of the extent, question is, can i convert it to real coordinates somehow? 

0: (2) [-9287098.97013145, 4619242.716943042]
1: (2) [-9287098.97013145, 5326132.3545241635]
2: (2) [-7173768.012103459, 5326132.3545241635]
3: (2) [-7173768.012103459, 4619242.716943042]
4: (2) [-9287098.97013145, 4619242.716943042]

@JohnGrayson wrote:

Depending on how you're going to use it, you should be able to directly use the MapView.extent as the 'search/selecting/etc' geometry.  If you absolutely need the geometry as a Polygon then maybe check out the 'fromExtent()' static method.



@JohnGrayson wrote:

Depending on how you're going to use it, you should be able to directly use the MapView.extent as the 'search/selecting/etc' geometry.  If you absolutely need the geometry as a Polygon then maybe check out the 'fromExtent()' static method.


0 Kudos
collaarwaar
New Contributor

@orahlagi these are 'real' coordinates but in I guess Webmercator-projection (wkid 3857), you want them in geographic coordinates (WGS84 wkid 4326)?

 

In that case there's a geometry-method to reproject webMercatorToGeographic , that might help you?