[OpenLayers-Users] no predefined zoomlevels

Christopher Schmidt crschmidt at metacarta.com
Mon Feb 12 11:11:06 EST 2007


On Mon, Feb 12, 2007 at 04:34:47PM +0100, Bart van den Eijnden (OSGIS) wrote:
> Hi Christopher,
> 
> I've seen this post. But isn't this to zoom to a specific scale?
>
> Or would I need to make my own set of controls and calculate the scale based
> on the zoombox the user has drawn, and then use the workaround from the
> post?

Yeah. What I would do:

I would make a subclass of the MouseWhatever control you are currently
using. Once you've done that, you replace the zoomBoxEnd function:
There's very litle you need to do other than copy the existing code and
change:

         var bounds = new OpenLayers.Bounds(left, bottom, right, top);
         this.map.zoomToExtent(bounds);

To instead calculate the resolution of the box and zoom to that scale,
then set the center. (or the other way around.)

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list