Hi All,

 

I have an application where I need to re-center the map when the user
requests that action.  Something very similar to what happens with the zoom
in and zoom out buttons from a JMapFrame.  Those buttons zoom in/out but
also center on where-ever the user clicks on the map.  I would like to do
the same but on a current point I have within the app.  The following code
snippet works but re-positions the map with the current point in the bottom
left of the display area:

 

   public void centerMapOnCurrentPos() {

      ReferencedEnvelope currentEnvelope =
mapFrame.getMapPane().getDisplayArea();

      double displayWidth = currentEnvelope.getWidth();

      double displayHeight = currentEnvelope.getHeight();

      double x = currentPoint.x;

      double y = currentPoint.y;

      Rectangle2D newArea= new
Rectangle2D.Double(x,y,displayWidth,displayHeight);

      

      GeneralEnvelope envelope = new GeneralEnvelope(newArea);

      mapFrame.getMapPane().setDisplayArea(envelope);

   }

 

I tried looking for the source for the zoom in/zoom out buttons but was
unable to find what actually does the centering.  Anyone have any
suggestions?

 

Thanks so much!

 

Dave

 

--------------------------------------------

David Purdy

Owner/President

JJM Technologies Corporation

Email:  [email protected]

signatureLogo

 

<<image001.gif>>

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to