simplegeo / polymaps

Polymaps is a free JavaScript library for making dynamic, interactive maps in modern web browsers.
http://polymaps.org/
Other
1.6k stars 213 forks source link

Tileset with 7 zoom levels on a map with 18 zoom levels #106

Closed RyanEwen closed 12 years ago

RyanEwen commented 12 years ago

Is there any way to tell Polymaps the range of available zoom levels for tiles, while still allowing zooming further?

Ex: I have an offline application which has tiles with zoom level 1-7 available. I still want users to be able to zoom in as close as level 18 (there are SVG objects on the map, the background tiles are just a bonus).

Right now the browser hammers the server for tiles that do not exist. I would like to be able to prevent Polymaps from requesting tiles for zoom level 8+.

Cheers,

Ryan

mbostock commented 12 years ago

Yes, you can hide the layer (by setting visible to false) when the map is at the higher zoom levels.

RyanEwen commented 12 years ago

Thanks for the quick reply!

Am I able to keep the closest zoom level visible? Ex: Show tiles for zoom level 7 while at 8, 9, 10, etc? Or am I making that layer hidden?

mbostock commented 12 years ago

You can do that by setting a zoom function on the layer, say, function(z) { return Math.min(7, z); }. "Currently, the transformed zoom level delta may be up to +2 and down to -4." So, you'll be able to go from 7 to 11 this way. Beyond that, the tiles would be unreasonably large and performance deteriorates, so you'll want to either limit zooming to have a reasonable constant-color background.

RyanEwen commented 12 years ago

Thanks, Mike!

That worked perfectly.