Re #1451. Re #1456. Change the way ScaleLine respectZoom is tested to test if the maxWidth of the control is respected at all zoom levels with two separate map units and with a custom maxWidth value.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6580 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA9XNhd8q0UdwNC7YSO4YZghSPUCi5aRYVveCcVYxzezM4iaj_gxQ9t-UajFL70jfcpquH5l1IJ-Zyyw'></script>
|
||||||
<script src="../../lib/OpenLayers.js"></script>
|
<script src="../../lib/OpenLayers.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
var validkey = (window.location.protocol == "file:") ||
|
||||||
|
(window.location.host == "localhost") ||
|
||||||
|
(window.location.host == "openlayers.org");
|
||||||
|
|
||||||
function test_initialize(t) {
|
function test_initialize(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
@@ -104,8 +108,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_respectZoom (t) {
|
function test_respectZoom (t) {
|
||||||
t.plan(5);
|
if(validkey) {
|
||||||
|
t.plan( 4 );
|
||||||
|
} else {
|
||||||
|
t.plan( 3 );
|
||||||
|
}
|
||||||
// ok, switch the units we use for zoomed in values. This will test that we're both
|
// ok, switch the units we use for zoomed in values. This will test that we're both
|
||||||
// correctly respecting all specified parameters and that we're switching to the
|
// correctly respecting all specified parameters and that we're switching to the
|
||||||
// "in" units when zoomed in
|
// "in" units when zoomed in
|
||||||
@@ -116,22 +123,49 @@
|
|||||||
map.addLayer(layer);
|
map.addLayer(layer);
|
||||||
map.zoomTo(0);
|
map.zoomTo(0);
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
t.eq(control.div.firstChild.innerHTML, "5000 mi", "top scale respects constructor parameter.");
|
var widthIsOk = true;
|
||||||
t.eq(control.div.lastChild.innerHTML, "10000 km", "bottom scale respects constructor parameter.");
|
for (var i=0; i<map.numZoomLevels && widthIsOk; i++) {
|
||||||
map.zoomIn();
|
map.zoomTo(i);
|
||||||
map.zoomIn();
|
var w1 = parseInt(control.eTop.style.width);
|
||||||
map.zoomIn();
|
var w2 = parseInt(control.eBottom.style.width);
|
||||||
map.zoomIn();
|
widthIsOk = w1 <= control.maxWidth && w2 <= control.maxWidth;
|
||||||
map.zoomIn();
|
}
|
||||||
map.zoomIn();
|
t.ok(widthIsOk, "respects maxWidth at all zoom levels in dd");
|
||||||
map.zoomIn();
|
|
||||||
map.zoomIn();
|
widthIsOk = true;
|
||||||
map.zoomIn();
|
control.maxWidth = 200;
|
||||||
map.zoomIn();
|
for (var i=0; i<map.numZoomLevels && widthIsOk; i++) {
|
||||||
map.zoomIn();
|
map.zoomTo(i);
|
||||||
|
var w1 = parseInt(control.eTop.style.width);
|
||||||
|
var w2 = parseInt(control.eBottom.style.width);
|
||||||
|
widthIsOk = w1 <= control.maxWidth && w2 <= control.maxWidth;
|
||||||
|
}
|
||||||
|
t.ok(widthIsOk, "respects modified maxWidth at all zoom levels in dd");
|
||||||
|
|
||||||
|
if (validkey) {
|
||||||
|
var map = new OpenLayers.Map('map');
|
||||||
|
var layer = new OpenLayers.Layer.Google('Goog Layer');
|
||||||
|
var control = new OpenLayers.Control.ScaleLine({topOutUnits : "mi", bottomOutUnits: "km", topInUnits: 'ft', bottomInUnits: 'm'});
|
||||||
|
map.addLayer(layer);
|
||||||
|
map.zoomTo(0);
|
||||||
|
map.addControl(control);
|
||||||
|
var widthIsOk = true;
|
||||||
|
for (var i=0; i<map.numZoomLevels && widthIsOk; i++) {
|
||||||
|
map.zoomTo(i);
|
||||||
|
var w1 = parseInt(control.eTop.style.width);
|
||||||
|
var w2 = parseInt(control.eBottom.style.width);
|
||||||
|
widthIsOk = w1 <= control.maxWidth && w2 <= control.maxWidth;
|
||||||
|
}
|
||||||
|
t.ok(widthIsOk, "respects maxWidth at all zoom levels in m");
|
||||||
|
} else {
|
||||||
|
t.debug_print("Google tests can't be run from " +
|
||||||
|
window.location.host);
|
||||||
|
}
|
||||||
|
|
||||||
|
var map = new OpenLayers.Map('map');
|
||||||
|
var layer = new OpenLayers.Layer.Google('Goog Layer');
|
||||||
|
map.addLayer(layer);
|
||||||
|
|
||||||
t.eq(control.div.firstChild.innerHTML, "10000 ft", "top scale zooms in & respects constructor parameter.");
|
|
||||||
t.eq(control.div.lastChild.innerHTML, "5000 m", "bottom scale zooms in & respects constructor parameter.");
|
|
||||||
map.destroy();
|
map.destroy();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user