0
Declined

Make zooming smoother (seems to be step-by-step right now)

John Smith 11 years ago updated by Jake Wilson (Lead Developer) 11 years ago 4
The more zoomed-out levels are really different. When you get close in they're closer together, but smoothing out the zooming would fix everything.

Answer

Answer
Declined

Smooth zooming with an infinite number of zoom levels would be pretty cool. Unfortunately, traditional mapping software like this is based around multiple zoom levels that the user zooms in and out of.  Just look at all major mapping websites out there like Google Maps or Bing Maps or Yahoo Maps etc...  It all centers around the idea that each zoom level has it's own set of map tiles.  So if one were to make a map with a smooth zoom, then it would essentially have an infinite number of zoom levels and then would need an infinite number of tiles as well.  Until someone out there tackles this approach to maps we are going to have to leave this off the drawing board for now.

Answer
Declined

Smooth zooming with an infinite number of zoom levels would be pretty cool. Unfortunately, traditional mapping software like this is based around multiple zoom levels that the user zooms in and out of.  Just look at all major mapping websites out there like Google Maps or Bing Maps or Yahoo Maps etc...  It all centers around the idea that each zoom level has it's own set of map tiles.  So if one were to make a map with a smooth zoom, then it would essentially have an infinite number of zoom levels and then would need an infinite number of tiles as well.  Until someone out there tackles this approach to maps we are going to have to leave this off the drawing board for now.

The solution to this would involve re-drawing the maps in a vector graphics format, which technically allows 'infinite' levels of zooming to be used pretty easily. But creating those vector graphics assets would be a lot of work for anything more than a basic sketch of the map/hex outlines and the information layers. 


There are open source tools for generating vector images from bitmaps, but they're not perfect in terms of quality. I assume it would require a large re-write of the website code to implement too.

Would it not be possible to load a certain detail level of the tiles when the zoom level gets between certain points? I.E. - When it's between, say, 90-100% zoom, load the max detail tiles, and then another range for the next detail level, etc. 

Seems a bit 'cheat-ey', but it should work. 

I understand what you are saying about loading higher level tiles at in-between zoom sizes.  It's actually not as easy as it sounds but it's something I will look into for the future.  Thanks for the suggestion.

No, the problem that lies in this map is the scroll levels of one's own mouse settings. When I scroll I go from all out to all in. This is easily fixed by disabling scroll zoom ( window.map.scrollWheelZoom.disable()/scrollWheelZoom: false ) and employing a window.map.zoomIn(1) on a mouse wheel's scroll one way, and window.map.zoomOut(1) for the other.


The two ways to do this are to use getWheelDelta( <DOMEvent> e ) from L.DomEvent or use the native JS listening process. Using the latter was simple to set up. Just create a function to do the zooming.


function zoomFine(e) {
   var evt=window.event || e; //equalise event object
   var delta=evt.detail? evt.detail*(-120) : evt.wheelDelta; //delta returns +120 when wheel is scrolled up, -120 when scrolled down
   zoomindex=(delta<=-120)? window.map.zoomOut(1): window.map.zoomIn(1);
   
   if (evt.preventDefault) { //disable default wheel action of scrolling page
     evt.preventDefault();
   } else {
     return false;
   }
}


and set up your listeners in your map initialiser:


var mouseWheelEvt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel";
       //FF doesn't recognize mousewheel as of FF3.x

   var mapDiv=document.getElementById("map");
   if (mapDiv.attachEvent) { //if IE (and Opera depending on user setting)
     mapDiv.attachEvent("on"+mouseWheelEvt, zoomFine);
   } else if (mapDiv.addEventListener) { //WC3 browsers
     mapDiv.addEventListener(mouseWheelEvt, zoomFine, false);
   }


Do not forget your default scroll wheel zoom disabler in window.map.scrollWheelZoom.disable() or with scrollWheelZoom: false in the map options.



There, the problem is practically solved :)…