AnsweredAssumed Answered

How to get map extent

Question asked by paul.haakma on Apr 12, 2018
Latest reply on Apr 12, 2018 by paul.haakma

Using the Runtime v100.x, how can you get the full extent of the map?


On the previous runtime, the 'Map' type had properties called 'extent' and 'fullExtent' which from memory gave Envelope objects.


In the new runtime, the MapView has a visibleArea which obviously changes as you pan around the map. It also has a currentViewpointExtent, which I guess kind of does the same thing.

The Map has layers, but no extent property.


When I create the Map object, I'm using a local tpk as the basemap, which has a small defined extent. After it loads, if the user has a network connection, I then add an online basemap under it for a bit of context. At this point, the user can pan to the edge of the tpk and no further. What I want to do now is detect if the current gps location is within this map extent, i.e. the extent of the tpk. So I need the map extent as a polygon object.


The basemap object of the Map doesn't even have an extent property.


So it seems that I'm forced to reach into the baseLayers object of the basemap and pull out the individual tpk layer, as a 'Layer' type *does* have a fullExtent property.


I could do this since I know which is the particular layer. But it seems like the MapView is already constrained to a certain extent and I should be able to just access that as a property of the view.


Bonus points if someone could say how to override the extent of the Map/MapView, in other words, if the online basemap does manage to load, how can I make it so the user can pan the full extent of that layer?