RE: [OpenMap Users] disallowing zooming out too far

From: Hudson Brian R Contr AFRL/IFSF <Brian.Hudson_at_rl.af.mil>
Date: Thu, 9 Sep 2004 18:39:24 -0000

Hey,
 
Think about it... it's a pretty basic if statement really...
 
It would look something like this:
 
float maxScale = ProjMath.getScale(upperLeft, lowerRight,
mapBean.getProjection())
 
float currentScale = mapBean.getProjection().getScale();
 
float newScale = currentScale * 1.5f;
 
if(newScale > maxScale) {
    newScale = maxScale;
}
 
mapBean.setScale(newScale);
 
 
Brian Hudson

-----Original Message-----
From: owner-openmap-users_at_bbn.com [mailto:owner-openmap-users_at_bbn.com] On
Behalf Of Ben Podoll
Sent: Thursday, September 09, 2004 1:35 PM
To: openmap-users_at_bbn.com
Subject: [OpenMap Users] disallowing zooming out too far



If I have the extents (upper left and lower right lat/lon coords) of the
domain I am interested in and I have a simple mouse mode that I made (seen
below)

 

public class ZoomOutMouseMode extends CoordMouseMode{

 

   //Member variable

   public final static transient String modeID = "ZoomOut";

   

   //Default Constructor

   public ZoomOutMouseMode(){}

 

   //A simple mouse mode to zoom out on a mouse press

   public ZoomOutMouseMode(boolean shouldConsumeEvents) {

      super(modeID, shouldConsumeEvents);

   }

 

   //Do a quick zoom out when the mouse is pressed

   public void mousePressed(MouseEvent e){

      e.getComponent().requestFocus();

      if(!mouseSupport.fireMapMousePressed(e) && e.getSource() instanceof
MapBean){

         MapBean mapBean = (MapBean)e.getSource();

         mapBean.setCenter((mapBean.getProjection()).inverse(e.getPoint()));

         mapBean.setScale(mapBean.getScale() * 1.5f);

      }

   }

}

 

How can I disallow them to zoom out further than those extents? As you can
also see I re-center the map when the user clicks to zoom out.

I basically don't want the user to ever see (or zoom out beyond) anything
outside the extents of interest (which are defined at startup).

 

I thought this would be easy but am finding it a bit difficult and was
hoping someone had done something similar before...

 

~Ben


--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Thu Sep 09 2004 - 14:42:43 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:06 EDT