Change the scale navigation events zoom on dynamic map

2869
11
Jump to solution
08-09-2013 11:56 AM
DerekMaune
Emerging Contributor
Is there a way to change the amount scale is increased/decreased by the mouse click and mouse scroll wheel navigation events on a Dynamic Map?  Failing that, is there a way to override the core portion of these functions?
0 Kudos
11 Replies
derekswingley1
Deactivated User
No server side config necessary, you can manually specify zoom levels for a map that doesn't use tiled services. But there's some work involved...

Background info:  the recommended, default way to use a JS API map is to create a map then add a tiled service. When you add a tiled service to a map, the map automatically uses the levels defined in that service as the levels for the map and sets the map's spatial reference to that of the tiled service. If you're not using a tiled service, the map doesn't know where to find zoom levels so, if you want specific zoom levels, you have to specify them when you create the map (as well as a spatial reference for the map). In my previous post in this thread, I linked to a post that has code that shows this. Here's a simplified version that creates a map, specifies three zoom levels and add a dynamic service. I've also specified sliderStyle: "large" so you can see a slider with ticks that represents the available zoom levels:  http://jsbin.com/adesan/1

For you to do this, you need to figure out which scales you want available in your app, then generate an array of LODs (levels of detail) that you pass to the map constructor when you create your map. The smallest scale will be level zero. As scales get larger, level number goes up. Levels also require a value for resolution which is the number of map units per pixel. You can get this number with the following line of code:

map.extent.getWidth() / map.width


Using that line of code along with map.getScale(), you can piece together an array of LODs to give to the map constructor.

If you want to specify a specific spatial reference, create an extent and pass that to the map constructor as the extent options. The feature layer in any projection sample is helpful for getting an extent in any spatial reference.
0 Kudos
DerekMaune
Emerging Contributor
It seems like I've built a decent lod array.  I'll have to play with it some more to make sure it works everywhere, but my issue is resolved.  Thanks for your help.
0 Kudos