Select to view content in your preferred language

How auto-resize works in 3.3??

695
1
02-04-2013 08:23 AM
HaoHu
by
New Contributor II
I noticed that the maps in 3.3 can auto-resizes, but I'm not sure how it works. I want to make sure the the map is resized when user change size of the browser. Here is my test code, I set the autoResize attribute but it doesn't work. Anyone can help? Thanks!


<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
    <title>Simple Map</title>
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/dojo/dijit/themes/claro/claro.css">
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/esri/css/esri.css">
    <style>
      html, body, #map {
        height:100%;
        width:100%;
        margin:0;
        padding:0;
      }
      body {
        background-color:#FFF;
        overflow:hidden;
        font-family:"Trebuchet MS";
      }
    </style>
    <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/"></script>
    <script>
        dojo.require("esri.map");
        var map;
        function init() {
            map = new esri.Map("map", {
                autoResize: true
            });

            var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer");
            map.addLayer(dynamicMapServiceLayer);
        }
        dojo.ready(init);

    </script>
  </head>

  <body class="claro">
    <div id="map"></div>
  </body>
</html> 
0 Kudos
1 Reply
JeffJacobson
Regular Contributor
When I pasted your code into jsfiddle it seemed to work just fine.

The What's new in 3.3 document describes what is required to set up auto-resize. It looks like the auto-resize option is actually enabled by default, so you do not have to explicitly set that option in your esri.Map constructor.
0 Kudos