How to get map extent

04-12-2018 05:23 AM
Regular Contributor

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? 

0 Kudos
2 Replies
Esri Regular Contributor

Yes, the fullextent property is only available on the Layer level. I would like to know how are you adding the tpk and the online basemap? Are you adding them as a part of basemap object or adding separately as layers. Because somethings get defined based on the first layer you load. 

In other words can you try loading the online basemap first and then load the tpk on top of that and see if you can pan outside the tpk?


0 Kudos
Regular Contributor

Hi Nakul

yeah I think you're on the money re the order of loading. I load the tpk first, then the online layer. So I could dynamically load the online layer first.

Hypothetically, if the user had no network connection when they started the app, and maybe I dynamically then load just the tpk. Then, then magically get network connection and I want to add the online basemap. I take it there would be no way to reset that extent without destroying and creating a new 'Map' object, is that correct?

Regardless of that, I still wonder whether there should be an extent property of the Map itself, as it obviously has one.

0 Kudos