Select to view content in your preferred language

Set maximum zoom in level

4071
8
10-18-2012 01:35 PM
MarkPaulson
Occasional Contributor
I'm a complete noob to Javascript and haven't done much programming in 15+ years, mainly autolisp. I have manage to get a map up and running using the identify with popup sample. http://www.geoiddata.com/pleasanton.html. My question is how do I limit the zoom in level so that I don't get the map data unavailable in background.

I also wanted a scale bar so I stuck in the following (bold text):

      function mapReady(map){

       dojo.connect(map,"onClick",executeIdentifyTask);
        
         var scalebar = new esri.dijit.Scalebar({
            map: map,
            scalebarUnit:'english'
          });
         
      
       
       //create identify tasks and setup parameters 
       identifyTask = new esri.tasks.IdentifyTask("http://www.geoiddata.com/ArcGIS/rest/services/Pleasanton/Pleasanton/MapServer");
       
       identifyParams = new esri.tasks.IdentifyParameters();
       identifyParams.tolerance = 3;
       identifyParams.returnGeometry = true;
       identifyParams.layerIds = [3,4];
       identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
       identifyParams.width  = map.width;
       identifyParams.height = map.height;
       
       
       //resize the map when the browser resizes
       dojo.connect(dijit.byId('map'), 'resize', map,map.resize);
  
      }


It works, but is that the best place to insert the scale bar code?
0 Kudos
8 Replies
JeffJacobson
Frequent Contributor
You need to assign a value to the lods option in the esri.Map constructor to limit the zoom levels.
0 Kudos
derekswingley1
Deactivated User
You need to assign a value to the lods option in the esri.Map constructor to limit the zoom levels.


That's the way to go. I've posted examples of how to do this in the past, most recently here:  http://forums.arcgis.com/threads/68743-Removing-LODS-after-the-map-has-loaded?p=239740&viewfull=1#po...
0 Kudos
MarkPaulson
Occasional Contributor
That's the way to go. I've posted examples of how to do this in the past, most recently here:  http://forums.arcgis.com/threads/68743-Removing-LODS-after-the-map-has-loaded?p=239740&viewfull=1#po...


Thank you both.
0 Kudos
JeffPace
MVP Alum
be careful though, while it works for max, it does not work for minimum if you use setLevel.

for example, if you do LOD 4-16, and then do setLevel(4) it goes to the 4th level, which in this case is level 7.  Very counter intuitive.
0 Kudos
derekswingley1
Deactivated User
be careful though, while it works for max, it does not work for minimum if you use setLevel.

for example, if you do LOD 4-16, and then do setLevel(4) it goes to the 4th level, which in this case is level 7.  Very counter intuitive.


This is true, the best approach would be to use zero through whatever to number your levels as you specify them in map.options.lods. I should have done this in the example but did a lazy copy/paste. Here's a better example:

lods: [
  {"level" : 0, "resolution" : 2445.98490512499, "scale" : 9244648.868618}, 
  {"level" : 1, "resolution" : 1222.99245256249, "scale" : 4622324.434309}, 
  {"level" : 2, "resolution" : 611.49622628138, "scale" : 2311162.217155}, 
  {"level" : 3, "resolution" : 305.748113140558, "scale" : 1155581.108577}, 
  {"level" : 4, "resolution" : 152.874056570411, "scale" : 577790.554289}, 
  {"level" : 5, "resolution" : 76.4370282850732, "scale" : 288895.277144}, 
  {"level" : 6, "resolution" : 38.2185141425366, "scale" : 144447.638572}, 
  {"level" : 7, "resolution" : 19.1092570712683, "scale" : 72223.819286}, 
  {"level" : 8, "resolution" : 9.55462853563415, "scale" : 36111.909643}, 
  {"level" : 9, "resolution" : 4.77731426794937, "scale" : 18055.954822}, 
  {"level" : 10, "resolution" : 2.38865713397468, "scale" : 9027.977411}
]
0 Kudos
JeffPace
MVP Alum
This is true, the best approach would be to use zero through whatever to number your levels as you specify them in map.options.lods. I should have done this in the example but did a lazy copy/paste. Here's a better example:

lods: [
  {"level" : 0, "resolution" : 2445.98490512499, "scale" : 9244648.868618}, 
  {"level" : 1, "resolution" : 1222.99245256249, "scale" : 4622324.434309}, 
  {"level" : 2, "resolution" : 611.49622628138, "scale" : 2311162.217155}, 
  {"level" : 3, "resolution" : 305.748113140558, "scale" : 1155581.108577}, 
  {"level" : 4, "resolution" : 152.874056570411, "scale" : 577790.554289}, 
  {"level" : 5, "resolution" : 76.4370282850732, "scale" : 288895.277144}, 
  {"level" : 6, "resolution" : 38.2185141425366, "scale" : 144447.638572}, 
  {"level" : 7, "resolution" : 19.1092570712683, "scale" : 72223.819286}, 
  {"level" : 8, "resolution" : 9.55462853563415, "scale" : 36111.909643}, 
  {"level" : 9, "resolution" : 4.77731426794937, "scale" : 18055.954822}, 
  {"level" : 10, "resolution" : 2.38865713397468, "scale" : 9027.977411}
]


I don't mean to get the thread of topic, but my concern with the above approach is what happens when we bring in other layers? for example AGO or OSM or a webtiledservice? if you use the {$row}/{$col}/{$lvl} url pattern, and are expecting lvl 10 to be the "universal" definition of 10 based on Google/Bing/ESRI, it causes lots of problems.

It would be really really nice if we could just leave the lods default, not have to define anything, and just say map.maxScale = 16 and map.minScale = 6
0 Kudos
derekswingley1
Deactivated User
I don't mean to get the thread of topic, but my concern with the above approach is what happens when we bring in other layers? for example AGO or OSM or a webtiledservice? if you use the {$row}/{$col}/{$lvl} url pattern, and are expecting lvl 10 to be the "universal" definition of 10 based on Google/Bing/ESRI, it causes lots of problems.


Agreed, the current way to do this has issues...


It would be really really nice if we could just leave the lods default, not have to define anything, and just say map.maxScale = 16 and map.minScale = 6


It's like you've been sitting in on our team meetings... I'm not committing to a timeline, but we're planning to add zoom, minZoom, maxZoom, minScale and maxScale properties to map.options to simplify this whole workflow. zoom would be used to specify the zoom level the map starts at, minZoom and maxZoom specify minimum and maxim zoom levels, if that's not obvious ;).
0 Kudos
JeffPace
MVP Alum
Agreed, the current way to do this has issues...



It's like you've been sitting in on our team meetings... I'm not committing to a timeline, but we're planning to add zoom, minZoom, maxZoom, minScale and maxScale properties to map.options to simplify this whole workflow. zoom would be used to specify the zoom level the map starts at, minZoom and maxZoom specify minimum and maxim zoom levels, if that's not obvious ;).


These would be awesome!! especially if they modify the zoom slider as well. 🙂
0 Kudos