From bf6ad055df599e35abe7f120310c685cd7a7f348 Mon Sep 17 00:00:00 2001 From: Schuyler Erle Date: Wed, 21 Jun 2006 17:12:19 +0000 Subject: [PATCH] Renamed zoomExtent to zoomToFullExtent, added tests for it and for the new lonlat/px convenience functions. git-svn-id: http://svn.openlayers.org/trunk/openlayers@663 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/PanZoom.js | 2 +- lib/OpenLayers/Map.js | 4 ++-- tests/test_Map.html | 20 ++++++++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/OpenLayers/Control/PanZoom.js b/lib/OpenLayers/Control/PanZoom.js index 5e8a374b48..5b51b118d5 100644 --- a/lib/OpenLayers/Control/PanZoom.js +++ b/lib/OpenLayers/Control/PanZoom.js @@ -137,7 +137,7 @@ OpenLayers.Control.PanZoom.prototype = this.map.zoomOut(); break; case "zoomworld": - this.map.zoomExtent(); + this.map.zoomToFullExtent(); break; } diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 68ce527de9..6c1e45d6bc 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -540,10 +540,10 @@ OpenLayers.Map.prototype = { }, /** - * zoomExtent + * zoomToFullExtent * Zoom to the full extent and recenter. */ - zoomExtent: function() { + zoomToFullExtent: function() { var fullExtent = this.getFullExtent(); var oldZoom = this.zoom; this.setCenter( diff --git a/tests/test_Map.html b/tests/test_Map.html index 3f83f9bf9e..7d285ddb00 100644 --- a/tests/test_Map.html +++ b/tests/test_Map.html @@ -59,7 +59,7 @@ t.eq( map.maxResolution, 3.14159, "map.maxResolution set correctly via options hash" ); } function test_05_Map_center(t) { - t.plan(4); + t.plan(7); map = new OpenLayers.Map($('map')); map.setCenter(new OpenLayers.LonLat(2, 1), 0); map.zoomIn(); @@ -68,7 +68,15 @@ t.eq( map.getCenter().lat, 1, "map center lat is correct after calling setCenter,zoom in"); map.zoomOut(); t.eq( map.getZoom(), 0, "map.zoom is correct after calling setCenter,zoom in, zoom out"); + map.zoomTo(5); + t.eq( map.getZoom(), 5, "map.zoom is correct after calling zoomTo" ); + map.zoomToFullExtent(); + t.eq( map.getZoom(), 0, "map.zoom is correct after calling zoomToFullExtent" ); + var lonlat = map.getCenter(); + var zero = new OpenLayers.LonLat(0, 0); + t.ok( lonlat.equals(zero), "map center is correct after calling zoomToFullExtent" ); } + function test_06_Map_zoomend_event (t) { t.plan(3); map = new OpenLayers.Map('map'); @@ -120,7 +128,7 @@ } function test_08_Map_px_lonlat_translation (t) { - t.plan( 3 ); + t.plan( 6 ); map = new OpenLayers.Map($('map')); map.setCenter(new OpenLayers.LonLat(0, 0), 0); @@ -136,6 +144,14 @@ // in the default case, it seems to work. This may not // always be so. t.ok( newPixel.equals(pixel), "Translation to pixel and back to lonlat is consistent"); + + lonlat = map.getLonLatFromPixel(pixel); + t.ok( lonlat instanceof OpenLayers.LonLat, "getLonLatFromPixel returns valid OpenLayers.LonLat" ); + + newPixel = map.getPixelFromLonLat(lonlat); + t.ok( newPixel instanceof OpenLayers.Pixel, "getPixelFromLonLat returns valid OpenLayers.Pixel" ); + + t.ok( newPixel.equals(pixel), "2nd translation to pixel and back to lonlat is consistent"); } function test_99_Map_destroy (t) {