Mobile Initial Extent different than Desktop

609
2
Jump to solution
01-13-2020 08:34 AM
MarquesMunson1
Occasional Contributor

Hello,

I am creating an application that shows the contiguous United States. I have set the view extent to load properly when opening the application on desktop. However, when opening on a mobile device or smaller screen, the map does not open at the same extent. It is more zoomed in than it should be. Any ideas on how to resolve this?

Thanks! 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

Version 3.x of the api has an option on the map's setExtent method to ensure the map shows the complete extent of what you've set. Unfortunately, version 4 doesn't have that option when setting the view's extent. You'll have to code that check yourself

view.when(() => {
  if(!view.extent.contains(yourExtent){
    view.zoom -= 1;
  }
});‍‍‍‍‍

View solution in original post

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

Version 3.x of the api has an option on the map's setExtent method to ensure the map shows the complete extent of what you've set. Unfortunately, version 4 doesn't have that option when setting the view's extent. You'll have to code that check yourself

view.when(() => {
  if(!view.extent.contains(yourExtent){
    view.zoom -= 1;
  }
});‍‍‍‍‍
0 Kudos
MarquesMunson1
Occasional Contributor

This worked, thanks so much!

0 Kudos