Hi Michael,
That is perfect! Thanks so much for the quick response! I put that in place and adapted it to my code and it worked perfectly. Thanks so much!! David From: Michael Bedward [mailto:[email protected]] Sent: Monday, July 22, 2013 10:06 PM To: David Purdy Cc: geotools users Subject: Re: [Geotools-gt2-users] Re-centering map on a Coordinate/Point Hi David, The centering is done by the onMouseClicked method of the zoom in and out tools. It's a pretty simple calculation. Have a look at the source below and you should be able to adapt it to your needs... https://github.com/geotools/geotools/blob/master/modules/unsupported/swing/s rc/main/java/org/geotools/swing/tool/ZoomInTool.java#L95 Michael On 23 July 2013 11:43, David Purdy <[email protected]> wrote: 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 ---------------------------------------------------------------------------- -- 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 <http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk > &iu=/4140/ostg.clktrk _______________________________________________ GeoTools-GT2-Users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
<<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
