AutoResize Map

2819
10
Jump to solution
07-28-2014 06:45 AM
jaykapalczynski
Frequent Contributor

I am a bit puzzled here.  I have to below code for my Map.

If I make the browser about half my screen and refresh everything is fine.

If I set the browser to Max size or manually make the browser window larger, the map does not expand to the full browser size?

I thought the below would take care of that.

Is there something else that I need to add.

    app.map = new esri.Map("map", {

       center: [-77.4329, 37.5410],

       zoom: 7,

       slider: true,

       showAttribution:true,

       logo: false,

      autoResize: true

    });

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Jay,

  OK Sorry I do see the issue when I have the browser started at a reduced size. I have run into this in the past and here is my workaround:

function adjustMapHeight() {

     var availHeight = $(window).height() - 40; //adjust for the header

     dom.byId("map").style.height = availHeight + "px";

}

function resizeMap() {

     adjustMapHeight();

     app.map.resize();

     app.map.reposition();

}

resizeEvt = (window.onorientationchange !== undefined && !has('android')) ? "orientationchange" : "resize";

on(window, resizeEvt, resizeMap);

View solution in original post

0 Kudos
10 Replies
RobertScheitlin__GISP
MVP Emeritus

Jay,

   Is your map inside a layout dijit?

0 Kudos
jaykapalczynski
Frequent Contributor

This is how the HTML is set up

<div id="map" class="map" style="width: 100%; height: 100%;">

      <div id="HomeButton"></div>

</div>

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jay,

   There must be something else in your code or css that is interfering with the maps resize. Can you post more of your code?

0 Kudos
jaykapalczynski
Frequent Contributor

REMOVED as the problem was found below and to safe space in the post this was not needed.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jay,

   I don't see that issue when using your link...

0 Kudos
jaykapalczynski
Frequent Contributor

Very interesting....I tested in Chrome and Firefox....when I expand the browser window It does not fully redraw....

hmmmm....it does not do this for you?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jay,

  OK Sorry I do see the issue when I have the browser started at a reduced size. I have run into this in the past and here is my workaround:

function adjustMapHeight() {

     var availHeight = $(window).height() - 40; //adjust for the header

     dom.byId("map").style.height = availHeight + "px";

}

function resizeMap() {

     adjustMapHeight();

     app.map.resize();

     app.map.reposition();

}

resizeEvt = (window.onorientationchange !== undefined && !has('android')) ? "orientationchange" : "resize";

on(window, resizeEvt, resizeMap);

0 Kudos
jaykapalczynski
Frequent Contributor

MODIFICATION.......brb going to test....

Thanks

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jay,

   They are fired when the browser window is resized or the orientation is changed (for mobile). I put these in your app and it worked

0 Kudos