diff --git a/src/OsmMapControl.java b/src/OsmMapControl.java
index 61865fe..39ddc99 100644
|
a
|
b
|
public class OsmMapControl extends MouseAdapter implements MouseMotionListener,
|
| 165 | 165 | iStartSelectionPoint = null; |
| 166 | 166 | } |
| 167 | 167 | else if(e.getClickCount() == 2){ |
| | 168 | iSlippyMapChooser.zoomIn(e.getPoint()); |
| 168 | 169 | iSlippyMapChooser.centerOnScreenPoint(e.getPoint()); |
| 169 | | iSlippyMapChooser.zoomIn(); |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | } |
| … |
… |
public class OsmMapControl extends MouseAdapter implements MouseMotionListener,
|
| 208 | 208 | int rot = e.getWheelRotation(); |
| 209 | 209 | //scroll wheel rotated away from user |
| 210 | 210 | if(rot < 0){ |
| 211 | | iSlippyMapChooser.zoomIn(); |
| | 211 | iSlippyMapChooser.zoomIn(e.getPoint()); |
| 212 | 212 | } |
| 213 | 213 | //scroll wheel rotated towards the user |
| 214 | 214 | else if(rot > 0){ |
| 215 | | iSlippyMapChooser.zoomOut(); |
| | 215 | iSlippyMapChooser.zoomOut(e.getPoint()); |
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | |
diff --git a/src/SlippyMapChooser.java b/src/SlippyMapChooser.java
index 6ca7b76..14e52d8 100644
|
a
|
b
|
public class SlippyMapChooser extends JComponent implements DownloadSelection{
|
| 355 | 355 | * Zoom in one level |
| 356 | 356 | * Callback for OsmMapControl. Zoom out one level |
| 357 | 357 | */ |
| 358 | | void zoomIn(){ |
| | 358 | void zoomIn(Point curPos){ |
| 359 | 359 | |
| 360 | 360 | //cache center of screen and the selection rectangle |
| 361 | | LatLon l = getLatLonOfScreenPoint(new Point(getWidth()/2, getHeight()/2)); |
| | 361 | LatLon l = getLatLonOfScreenPoint(curPos); |
| 362 | 362 | LatLon selStart = null; |
| 363 | 363 | LatLon selEnd = null; |
| 364 | 364 | if(iSelectionRectEnd != null && iSelectionRectStart != null){ |
| … |
… |
public class SlippyMapChooser extends JComponent implements DownloadSelection{
|
| 373 | 373 | return; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | | //center on cached location |
| 377 | | centerOnLatLon(l); |
| | 376 | setLatLonAtPoint(l, curPos); |
| 378 | 377 | |
| 379 | 378 | //restore selection |
| 380 | 379 | if(selStart != null && selEnd != null){ |
| … |
… |
public class SlippyMapChooser extends JComponent implements DownloadSelection{
|
| 393 | 392 | * Zoom out one level. |
| 394 | 393 | * Callback for OsmMapControl. |
| 395 | 394 | */ |
| 396 | | void zoomOut(){ |
| | 395 | void zoomOut(Point curPos){ |
| 397 | 396 | //cache center of screen and the selction rect |
| 398 | | LatLon l = getLatLonOfScreenPoint(new Point(getWidth()/2, getHeight()/2)); |
| | 397 | LatLon l = getLatLonOfScreenPoint(curPos); |
| 399 | 398 | LatLon selStart = null; |
| 400 | 399 | LatLon selEnd = null; |
| 401 | 400 | if(iSelectionRectEnd != null && iSelectionRectStart != null){ |
| … |
… |
public class SlippyMapChooser extends JComponent implements DownloadSelection{
|
| 410 | 409 | return; |
| 411 | 410 | } |
| 412 | 411 | |
| 413 | | //center on cached location |
| 414 | | centerOnLatLon(l); |
| | 412 | setLatLonAtPoint(l, curPos); |
| 415 | 413 | |
| 416 | 414 | //restore selection |
| 417 | 415 | if(selStart != null && selEnd != null){ |
| … |
… |
public class SlippyMapChooser extends JComponent implements DownloadSelection{
|
| 484 | 482 | * Centers the map on the location given by LatLon |
| 485 | 483 | * @param aLatLon the location to center on |
| 486 | 484 | */ |
| 487 | | private void centerOnLatLon(LatLon aLatLon){ |
| | 485 | private void centerOnLatLon(LatLon aLatLon){ |
| | 486 | setLatLonAtPoint(aLatLon, new Point(getWidth()/2,getHeight()/2)); |
| | 487 | } |
| | 488 | |
| | 489 | /** |
| | 490 | * Moves the map that the specified latLon is shown at the point on screen |
| | 491 | * given |
| | 492 | * @param aLatLon a position |
| | 493 | * @param p a point on the screen |
| | 494 | */ |
| | 495 | private void setLatLonAtPoint(LatLon aLatLon, Point p){ |
| 488 | 496 | int x = OsmMercator.LonToX(aLatLon.lon(), iZoomlevel); |
| 489 | 497 | int y = OsmMercator.LatToY(aLatLon.lat(), iZoomlevel); |
| 490 | | iOffsetX = -x +getWidth()/2; |
| 491 | | iOffsetY = -y +getHeight()/2; |
| | 498 | iOffsetX = - x + p.x; |
| | 499 | iOffsetY = - y + p.y; |
| 492 | 500 | repaint(); |
| 493 | 501 | } |
| 494 | 502 | |