Select to view content in your preferred language

Scalebar disappears when zoomed out a lot?

863
4
11-09-2011 10:59 AM
RexBradford
Emerging Contributor
I have an app which starts out with a wide extent (left edge is west of African continent, right edge is right of Chinese coast).

The scalebar initially appears, with 0-2000km as its range.

If I pan, the scalebar disappears at the end of the pan, and never returns until I zoom in significantly.  Then the scalebar disappears when zoomed out again.  I.e., the scalebar is always absent when zoomed well out, except on initial draw.

After initial draw, even switching to another browser window and switching back causes scalebar to disappear.

Initial extent:
    extentXMin: -4414756.0,
    extentYMin: -4416634.0,
    extentXMax: 16092382.0,
    extentYMax: 9032981.0,

If I start out more zoomed in, scalebar works fine until zoom out and then disappears again while zoomed out.

I do not have a small test case that exhibits this, just wondering if somebody has seen this kind of thing before and might point me in the right direction.

Rex Bradford
Direct Relief International
0 Kudos
4 Replies
derekswingley1
Deactivated User
I put together a simple test case using the coords you posted:
<!doctype html>
<html lang="en">
  <head>
    <meta 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></title>
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/dojo/dijit/themes/tundra/tundra.css">
    <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.5/js/esri/dijit/css/Popup.css">
    <style>
      html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
      #map{ margin: 0; padding: 0; }
    </style>
    <script>var dojoConfig = { parseOnLoad: true };</script>
    <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.5"></script>
    <script>
      dojo.require("dijit.layout.BorderContainer");
      dojo.require("dijit.layout.ContentPane");
      dojo.require("esri.map");
      dojo.require("esri.dijit.Scalebar");
      
      var map;
      function init() {
        // var initExtent = new esri.geometry.Extent({"xmin":-17878954,"ymin":-2368856,"xmax":11003235,"ymax":12170078,"spatialReference":{"wkid":102100}});
        var initExtent = new esri.geometry.Extent({"xmin":-4414756,"ymin":-4416634,"xmax":16092382,"ymax":9032981,"spatialReference":{"wkid":102100}});
        
        map = new esri.Map("map",{
          extent:initExtent,
          wrapAround180: true
        });
        var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
        map.addLayer(basemap);
        
        dojo.connect(map, 'onLoad', function() { 
          dojo.connect(dijit.byId('map'), 'resize', map, map.resize);
          
          var scalebar = new esri.dijit.Scalebar({
            map: map,
            scalebarUnit:'metric'
          });
          
        });
      }
      dojo.ready(init);
    </script>
  </head>
  
  <body class="tundra">
    <div data-dojo-type="dijit.layout.BorderContainer" 
         data-dojo-props="design:'headline',gutters:false" 
         style="width: 100%; height: 100%; margin: 0;">
      <div id="map" 
           data-dojo-type="dijit.layout.ContentPane" 
           data-dojo-props="region:'center'"> 
      </div>
    </div>
  </body>
</html>


And can't repro it...can you try to come up with a simple test case?

On JSFiddle:  http://jsfiddle.net/swingley/PC7GB/
0 Kudos
KevinBoone
Emerging Contributor
Derek, I just tested the JSFiddle link with Firefox 7.0.1 and I see the error. Specifically, if I zoom out to the lowest notch of the zoom slider, the scalebar disappears. When I zoom back in one step at a time, the scalebar doesn't re-appear until the initial extent (3rd notch from bottom of zoom slider, when lowest notch is counted as 1). Screen res is 1440x900 and Firefox window was maximized.
0 Kudos
JianHuang
Deactivated User
It's expected behavior that scalebar disappears when zooming out to level 1 or 2 of the world map. We did it on purpose since there is no accurate scale value when the map covers the whole world.
But it should come back when zooming in again. If it's not the case, please provide a reproducible case.
Thanks a lot.
0 Kudos
RexBradford
Emerging Contributor
It's expected behavior that scalebar disappears when zooming out to level 1 or 2 of the world map. We did it on purpose since there is no accurate scale value when the map covers the whole world.
But it should come back when zooming in again. If it's not the case, please provide a reproducible case.
Thanks a lot.


No, sorry if I wasn't clear.  It does come back when I zoom in, and what you say about not showing it when zoomed way out makes sense.

The only odd thing is that the scalebar does appear in the initial map draw when zoomed out, and then disappears if you pan or resize browser or do almost anything.
0 Kudos