You could check whether the values are within an acceptable range in the
function that redraws and only do anything at all if they are. This is kind of
hacky though.
Lars
Yes, you can set the extent for x, y and z as of v2.5.0, e.g.
.call(d3.behavior.zoom()
.extent([
[-Infinity, Infinity],
[-Infinity, Infinity],
[0, Infinity]
])
.on("zoom", redraw));
--
Jason Davies, http://www.jasondavies.com/
Cool! What are the values, projected or original coordinates? I've played around
with this but couldn't get it to work properly :( If I use unprojected
coordinates to set the extent, it breaks when I zoom in, i.e. the extent is much
smaller then than what I set.
Lars
It uses pixel-space coordinates i.e. projected. The z-range denotes the
allowed zoom levels, so zoom level 1 means everything is doubled in
size, 2 means everything is quadrupled, etc.
Ah, ok. I was trying to limit the extent to a section of the map (i.e.
unprojected coordinate bounds). Am I right in thinking that I would need to
reset the extent after each zoom to do that?
Lars
Hmm, I will have to think about this. It *should* be possible by
setting an extent using the projected coordinate bounds. But it didn't
seem to work, so I'll need to look into it and get back to you. :)
Thanks. That seemed like an obvious use case to me (at least I've wanted to do
this). Maybe that should be a separate function though (à la geotransform issue)
to keep the current functionality.
Lars