Index: applications/editors/josm/plugins/wmsplugin/resources/ymap.html
===================================================================
--- applications/editors/josm/plugins/wmsplugin/resources/ymap.html	(revision 10544)
+++ applications/editors/josm/plugins/wmsplugin/resources/ymap.html	(revision 10585)
@@ -2,7 +2,7 @@
   <head>
     <script type="text/javascript">
-		var bbox = "";
-        var width  = 800;
-        var height = 800;
+		//var bbox = "";
+        //var width  = 800;
+        //var height = 800;
 
 		// Parse query string and set variables
@@ -27,9 +27,9 @@
         
         // Limit size to current window's, to avoid memory problems
-        width = Math.min(width, screen.width);
-        height = Math.min(height, screen.height);
+        //width = Math.min(width, screen.width);
+        //height = Math.min(height, screen.height);
         
     </script>
-    <script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.4&appid=z7qRk3_V34HAbY_SkC7u7GAgG5nDTblw.cuL1OS5LWGwkIIUeGjg4qsnJDPpmhoF"></script>
+    <script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=z7qRk3_V34HAbY_SkC7u7GAgG5nDTblw.cuL1OS5LWGwkIIUeGjg4qsnJDPpmhoF"></script>
   </head>
   
@@ -43,57 +43,63 @@
       else
       {
-          // Resize map container to parameter dimension
-          var mapDiv = document.getElementById("map");
-          mapDiv.style.width  = Math.ceil(width/258)*258;
-          mapDiv.style.height = Math.ceil(height/258)*258;
+        // Resize map container to parameter dimension
+        var mapDiv = document.getElementById("map");
 
-          // Get the bounding box
-          var coords = bbox.split(",");
-          var tllon  = coords[0], tllat = coords[1];
-          var brlon  = coords[2], brlat = coords[3];
+        // Get the bounding box
+        var coords = bbox.split(",");
+        var tllon  = Number(coords[0]), tllat = Number(coords[1]);
+        var brlon  = Number(coords[2]), brlat = Number(coords[3]);
 
-          var points = new Array();
-          points[0] = new YGeoPoint(tllat, tllon);
-          points[1] = new YGeoPoint(brlat, brlon);
+        var points = new Array();
+        points[0] = new YGeoPoint(tllat, tllon);
+        points[1] = new YGeoPoint(brlat, brlon);
 
-          // other map types work as well but only satellite allowed for use with OSM!
-          var map = new YMap(document.getElementById("map"), YAHOO_MAP_SAT);
-          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--;
-           
-           map.drawZoomAndCenter(zac.YGeoPoint,level);
+        // other map types work as well but only satellite allowed for use with OSM!
+        var map = new YMap(document.getElementById("map"), YAHOO_MAP_SAT, new YSize(width, height));
+        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--;
 
-		  // Get the on-screen coordinates of the points
-		  xy0 = map.convertLatLonXY(points[0]);
-		  xy1 = map.convertLatLonXY(points[1]);
-		  
-		  // Create a new size for the map. This makes the need of clipping the image unnecesary.
-		  new_width  = Math.abs( xy0.x - xy1.x);
-		  new_height = Math.abs( xy0.y - xy1.y);
-		  
-		  // Apply the new width-height
-          mapDiv.style.width  = new_width;
-          mapDiv.style.height = new_height;
-          map.resizeTo( new YSize(new_width, new_height));
+        map.drawZoomAndCenter(zac.YGeoPoint,level);
+
+        // Get the on-screen coordinates of the points
+        xy0 = map.convertLatLonXY(points[0]);
+        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));
+        map.drawZoomAndCenter(cx,level)
+      
+        dump(xy0.x + " " + xy0.y + " " + xy1.x + " " + xy1.y + "\n");
+        dump(tllat + " " + tllon + " " + brlat + " " + brlon + "\n");
+        dump((brlat + tllat)/2 + " " + (brlon + tllon)/2 + "\n");
+        
+        // Create a new size for the map. This makes the need of clipping the image unnecessary.
+        new_width  = Math.abs( xy0.x - xy1.x);
+        new_height = Math.abs( xy0.y - xy1.y);
+        
+        // Apply the new width-height
+        mapDiv.style.width  = new_width;
+        mapDiv.style.height = new_height;
+        map.resizeTo( new YSize(new_width, new_height));
+        window.moveTo(0,0);
+        window.resizeTo(new_width, new_height);
+
+
           
-		  /// DEBUG: colour the interesting area
-		  var cPT2 = new YGeoPoint(tllat, tllon); 
-		  var cPT3 = new YGeoPoint(tllat, brlon); 
-		  var cPT4 = new YGeoPoint(brlat, brlon); 
-		  var cPT5 = new YGeoPoint(brlat, tllon); 
-		  // args: array of pts, color, width, alpha 
-		  var poly1 = new YPolyline([cPT2,cPT3,cPT4,cPT5, cPT2],'blue',7,0.7); 
-		  //map.addOverlay(poly1);
-		 
-          var bounds = map.getBoundsLatLon();
-
-          //Resizes to the actual bounding box
-			 window.moveTo(0,0);
-			 window.resizeTo(new_width,new_height);
+        /*
+        /// DEBUG: colour the interesting area
+        var cPT2 = new YGeoPoint(tllat, tllon); 
+        var cPT3 = new YGeoPoint(tllat, brlon); 
+        var cPT4 = new YGeoPoint(brlat, brlon); 
+        var cPT5 = new YGeoPoint(brlat, tllon); 
+        // args: array of pts, color, width, alpha 
+        var poly1 = new YPolyline([cPT2,cPT3,cPT4,cPT5, cPT2],'blue',7,0.7); 
+        map.addOverlay(poly1);
+        */
       }
     </script>
