Change to getZoomForResolution() (and those who call it) so that it does not choose the closest fit by default. Doing so was causing us problems, because user would drag a zoom box and then the map's new zoom would not contain said zoombox. Not good. Default is back to how it was before, but now there's an option 'closest' for those times when what we really want is the closest. Right now, the only time that's true is when we're switching baselayers. This is based on the work from sandbox/euzuro/zoomToResolution, which is started by reverting r4318. (Closes #1043)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@4792 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2007-10-03 19:21:05 +00:00
parent cb494d0c3f
commit 137a69b17a
9 changed files with 86 additions and 122 deletions

View File

@@ -43,33 +43,21 @@
var overviewZoom = control.ovmap.getZoom();
t.eq(overviewCenter.lon, -71, "Overviewmap center lon correct");
t.eq(overviewCenter.lat, 42, "Overviewmap center lat correct");
t.eq(overviewZoom, 9, "Overviewmap zoomcorrect");
t.eq(overviewZoom, 8, "Overviewmap zoomcorrect");
control.mapDivClick({'xy':new OpenLayers.Pixel(5,5)});
// There are box model issues that keep browsers from giving us
// identical results here. Test the normalized difference against
// a tolerance instead of testing equality.
function normalizedDiff(a, b) {
return Math.abs((a - b) / (a + b));
}
var tolerance = 1e-4;
var cent = map.getCenter();
t.ok(normalizedDiff(cent.lon, -71.00390625) < tolerance,
"Clicking on the Overview Map has the correct effect on map lon");
t.ok(normalizedDiff(cent.lat, 42.00390625) < tolerance,
"Clicking on the Overview Map has the correct effect on map lat");
t.eq(cent.lon, -71.3515625, "Clicking on the Overview Map has the correct effect on map lon");
t.eq(cent.lat, 42.17578125, "Clicking on the Overview Map has the correct effect on map lat");
control.rectMouseDown({'xy':new OpenLayers.Pixel(5,5), 'which':1});
control.rectMouseMove({'xy':new OpenLayers.Pixel(15,15), 'which':1});
control.rectMouseUp({'xy':new OpenLayers.Pixel(15,15), 'which':1});
var cent = map.getCenter();
t.ok(normalizedDiff(cent.lon, -70.83984375) < tolerance,
"Dragging on the Overview Map has the correct effect on map lon");
t.ok(normalizedDiff(cent.lat, 41.84765625) < tolerance,
"Dragging on the Overview Map has the correct effect on map lat");
t.eq(cent.lon, -71.2734375, "Dragging on the Overview Map has the correct effect on map lon");
t.eq(cent.lat, 42.09765625, "Dragging on the Overview Map has the correct effect on map lat");
map.setCenter(new OpenLayers.LonLat(0,0), 0);
var overviewCenter = control.ovmap.getCenter();