Respecting fractional zoom when desired. Allowing string argument to map.zoomTo. r=bartvde (closes #2180)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10026 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1576,7 +1576,13 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
moveTo: function(lonlat, zoom, options) {
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
}
|
||||
if (zoom != null) {
|
||||
zoom = parseFloat(zoom);
|
||||
if (!this.fractionalZoom) {
|
||||
zoom = Math.round(zoom);
|
||||
}
|
||||
}
|
||||
// dragging is false by default
|
||||
var dragging = options.dragging;
|
||||
// forceZoomChange is false by default
|
||||
@@ -1658,7 +1664,7 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
}
|
||||
|
||||
if (zoomChanged) {
|
||||
this.zoom = parseInt(zoom);
|
||||
this.zoom = zoom;
|
||||
this.resolution = this.getResolutionForZoom(zoom);
|
||||
// zoom level has changed, increment viewRequestID.
|
||||
this.viewRequestID++;
|
||||
|
||||
@@ -1053,6 +1053,46 @@
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_zoomTo(t) {
|
||||
t.plan(8);
|
||||
|
||||
var map = new OpenLayers.Map("map");
|
||||
map.addLayer(new OpenLayers.Layer(null, {
|
||||
isBaseLayer: true
|
||||
}));
|
||||
|
||||
map.zoomToMaxExtent();
|
||||
|
||||
map.zoomTo(2);
|
||||
t.eq(map.getZoom(), 2, 'zoomTo(2)');
|
||||
|
||||
map.zoomTo(3.6);
|
||||
t.eq(map.getZoom(), 4, 'zoomTo(3.6)');
|
||||
|
||||
map.zoomTo("4.6");
|
||||
t.eq(map.getZoom(), 5, 'zoomTo("4.6")');
|
||||
|
||||
map.zoomTo("1.2");
|
||||
t.eq(map.getZoom(), 1, 'zoomTo("1.2")');
|
||||
|
||||
// now allow fractional zoom
|
||||
map.fractionalZoom = true;
|
||||
|
||||
map.zoomTo(2);
|
||||
t.eq(map.getZoom(), 2, '[fractionalZoom] zoomTo(2)');
|
||||
|
||||
map.zoomTo(3.6);
|
||||
t.eq(map.getZoom(), 3.6, '[fractionalZoom] zoomTo(3.6)');
|
||||
|
||||
map.zoomTo("4.6");
|
||||
t.eq(map.getZoom(), 4.6, '[fractionalZoom] zoomTo("4.6")');
|
||||
|
||||
map.zoomTo("1.2");
|
||||
t.eq(map.getZoom(), 1.2, '[fractionalZoom] zoomTo("1.2")');
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Map_getUnits(t) {
|
||||
t.plan(2);
|
||||
var map = new OpenLayers.Map("map");
|
||||
|
||||
Reference in New Issue
Block a user