jquery mobile new release ... screen not filling out.

791
3
06-21-2011 07:49 PM
IainCampion
New Contributor III
Hi Guys,

anyone playing around with the js and jquery mobile latest release. (beta 1)

I've discovered that on the iPad2 the bottom portion of the screen isn't filled out to the full length?

Cheers
Coomsie
0 Kudos
3 Replies
SteveClarke
New Contributor
I've had the same problem with Beta 1.  I could get the map to display full with Alpha 4.1 by using the following parameters:

<style type="text/css">
   #map{
        width:100%;
        height:100%;
      }
    </style>

<div data-role="page" id="mapView" style="width:100%;height:100%;overflow:hidden;" data-theme="b">
  
<div data-role="content" id="mapcontent" style="width:100%;height:100%;padding:0px;">
   <div id="map"></div>

By setting the css above and these style's with the div's for data-role's "page" and "content" then the map will display full.  Also, I found that another requirement to get the map to display full is to make sure your code for displaying the map is first in the body of the html document.  This is especially important if you are placing multiple pages within the html document.  Hope this helps.
0 Kudos
SteveClarke
New Contributor
Please note that I'm not an esri employee even though the esri logo is showing up beneath my name on the left of the forum posting.  I've requested the forum administrator to remove it so as not to cause confusion.
0 Kudos
SteveClarke
New Contributor
The only way that the map will display the full width and height of the browser window is if you specify the width and height of the map in pixels and not percentages.  For example, the following would set the map to 600 pixels by 600 pixels. 

<style type="text/css">
   #map{
        width:600px;
        height:600px;
      }
</style>

But this is a pain because you can only hardcode the dimensions for the map for one device and it will not take into account devices with different screen sizes.  But I found the following code that will detect the width and height of the display canvas of your application for the device you are using and automatically adjust the map's dimensions to those calculated numbers. 

<script language="JavaScript">
   function viewPort() {
         var h = window.innerHeight || document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight;
         var w = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth;
        
         return { width : w , height : h }
        }
 
  var mapH = viewPort().height+20;
  var mapW = viewPort().width;
 
  $(document).ready(function() {
    $("#map").css({"width":mapW+"px","height":mapH+"px"});
  }); 
</script>

This code only applies to the map's width and height.  You still need to set the padding to 0px in the div of your code.

<div data-role="content" id="mapcontent" style="padding:0px">
      <div id="map"></div>
</div>

I added 20 additional pixels for the height because I found that on my iOS device the map was just a little short and displayed a small blank area at the bottom of the screen.  The additional 20 pixels fills out the map to the full height of the device.  I don't know if this extra 20 pixels is required for other devices but it's not significant.  I've tested this code on iOS devices and one Android 2.3 phone and it works just fine.
0 Kudos