Index: applications/editors/josm/plugins/wmsplugin/resources/ymap.html
===================================================================
--- applications/editors/josm/plugins/wmsplugin/resources/ymap.html	(revision 12486)
+++ applications/editors/josm/plugins/wmsplugin/resources/ymap.html	(revision 12491)
@@ -50,9 +50,8 @@
         map.removeZoomScale();
         var zac = map.getBestZoomAndCenter(points);
-        var level = zac.zoomLevel;
-
-        // funny Yahoo bug seems to return 0 if your section is too small
-        if( level == 0 ) level = 1;
-        if (level>1) level--;
+        var level = zac.zoomLevel-1;
+        var levels = map.getZoomValidLevels();
+        if(levels[0] > level)
+          level = levels[0];
 
         map.drawZoomAndCenter(zac.YGeoPoint,level);
@@ -62,6 +61,6 @@
         xy1 = map.convertLatLonXY(points[1]);
 
-        // This is hack to bug in getBestZoomAndCenter function
-        cx = map.convertXYLatLon(new YCoordPoint((xy0.x+xy1.x)/2, (xy0.y+xy1.y)/2));
+        // Recenter the stuff to have exact edges
+        cx = map.convertXYLatLon(new YCoordPoint((xy0.x+xy1.x)/2.0, (xy0.y+xy1.y)/2.0));
         map.drawZoomAndCenter(cx,level)
 
