Compare commits

...

20 Commits

Author SHA1 Message Date
crschmidt 136393864b Tagging 2.0 branch for RC6.
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.0-rc6@1363 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 18:51:29 +00:00
crschmidt 5987d5ea33 (continuation of r1359) -- tschaub points out that zoomBox and measureBox
are not the same thing, and also points out that he's already fixed the 
problem in a different and better way. Add in half of his patch, and keep
the other on the back burner until I can review post 2.0 and see how much
of this code needs a rewrite anyway.


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1360 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 15:20:48 +00:00
crschmidt b5153746f6 git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1359 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf 2006-08-24 15:19:18 +00:00
crschmidt fb663b5127 If we turn on the zooming tool, then click on the panzoombar in IE,
because the click drops through (Why god Why?!) we get an error telling
us that evt.xy doesn't exist, so we wrap it in an if statement which
protects us. (Deliver us, o if statement, from IEvil...) 


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1358 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 15:07:18 +00:00
crschmidt 1f9cb14069 When you click and don't drag, we zoom in, but we want to set performedDrag,
since that's how we ensure that we don't fire click.


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1357 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 14:52:39 +00:00
crschmidt 6fe0826a54 Change zoomBox function to be a 'zoom in' if the user draws a very small box.
In order to remove duplicate code, make MouseToolbar a subclass of 
MouseDefaults, and create zoomBoxEnd method. 


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1356 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 14:21:45 +00:00
crschmidt e61545167d Map should change zoom level to maximum for the baseLayer when the baseLayer
changes, rather than trying to set it to 17, which will fail, and leave the 
zoom level as null, and then everything explodes. Thanks to Heidi Fox at MC
for this report.


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1355 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 14:08:18 +00:00
crschmidt d564f2da47 Add tests for MouseToolbar. This is relatively minimal compared to what
really should be done, but this will catch the problems encountered in RC3
automatically if the tests are run in IE. 


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1354 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 13:35:55 +00:00
crschmidt 5320cd290c Dragging stopped by Event.stop call when it shouldn't have been -- no
need for this. Only stop event if mousedown started in zoombar. 


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1353 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 05:59:12 +00:00
crschmidt a50b175b66 Because we've removed the ruler button, its image no longer needs changing
when we change modes to/from that mode. Remember that.


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1352 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 05:49:02 +00:00
crschmidt 739b821570 console.log is NOT VALID JAVASCRIPT. Soon I will need to just create a wrapper
function which does nothing, if I keep up these crappy commits.


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1350 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 05:19:20 +00:00
crschmidt 82f786c630 Restore maxZoomLevel functionality, removoed between rc1 and rc2 by Erik.
This was the *only* way of setting zoom levels up until 2.0, taking it away
in an RC release is bad. (This resolves Jeff Dege's most recent mail to the
users list.)


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1348 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 05:11:28 +00:00
crschmidt eb783aab37 If we choose to switch to a mode via the toolbar, don't leave that mode
until we're explicitly told to. This allows users to click the zoombox
and zoom several times.


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1347 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 05:01:10 +00:00
Schuyler Erle a668730ec1 Replicating r1345 in 2.0 branch.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1346 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 04:21:27 +00:00
crschmidt 3aca63eabe Before, this example only worked on OpenLayers.org.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1343 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-23 21:05:15 +00:00
crschmidt 7ca9d2ec83 And it helps if you do the order of operations right so that the figures
are not rounded to integers, really.


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1342 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-23 21:04:14 +00:00
crschmidt 0500b9cba2 KaMap used to round its tiles. This dropped out. This was bad, since it means
any existing KaMap caches were not working correctly with 2.0-rc2.


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1341 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-23 20:59:37 +00:00
crschmidt 581df4e5f1 Commit r1337 to 2.0 branch.
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1340 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-23 20:55:04 +00:00
crschmidt a7da80c24b Until we have line drawing, there's no need for ruler-ing. It's confusing
users. 


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1339 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-23 20:39:22 +00:00
crschmidt 00dfc669d2 If we're zooming with this tool, we only want to actually change the zoom if
the box was bigger than 5px in one direction or another. If it was smaller 
than that, the user probably just clicked, rather than drawing a box, because 
the MouseToolbar icon is kind of misleading.


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.0@1338 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-23 20:37:16 +00:00
12 changed files with 121 additions and 46 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
{layers: 'basic'} ); {layers: 'basic'} );
var jpl_wms = new OpenLayers.Layer.KaMap( "Satellite", var jpl_wms = new OpenLayers.Layer.KaMap( "Satellite",
"/world/index.php", {g: "satellite", map: "world"}); "http://www.openlayers.org/world/index.php", {g: "satellite", map: "world"});
var dm_wms = new OpenLayers.Layer.WMS( "Canada", var dm_wms = new OpenLayers.Layer.WMS( "Canada",
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap", "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
{layers: "bathymetry,land_fn,park,drain_fn,drainage," + {layers: "bathymetry,land_fn,park,drain_fn,drainage," +
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

+36 -16
View File
@@ -60,6 +60,7 @@ OpenLayers.Control.MouseDefaults.prototype =
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(newCenter, this.map.zoom + 1); this.map.setCenter(newCenter, this.map.zoom + 1);
Event.stop(evt); Event.stop(evt);
return false;
}, },
/** /**
@@ -80,6 +81,7 @@ OpenLayers.Control.MouseDefaults.prototype =
this.zoomBox.style.backgroundColor = "white"; this.zoomBox.style.backgroundColor = "white";
this.zoomBox.style.filter = "alpha(opacity=50)"; // IE this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
this.zoomBox.style.opacity = "0.50"; this.zoomBox.style.opacity = "0.50";
this.zoomBox.style.fontSize = "1px";
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
this.map.viewPortDiv.appendChild(this.zoomBox); this.map.viewPortDiv.appendChild(this.zoomBox);
} }
@@ -95,8 +97,8 @@ OpenLayers.Control.MouseDefaults.prototype =
if (this.zoomBox) { if (this.zoomBox) {
var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x); var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y); var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);
this.zoomBox.style.width = deltaX+"px"; this.zoomBox.style.width = Math.max(1, deltaX) + "px";
this.zoomBox.style.height = deltaY+"px"; this.zoomBox.style.height = Math.max(1, deltaY) + "px";
if (evt.xy.x < this.mouseDragStart.x) { if (evt.xy.x < this.mouseDragStart.x) {
this.zoomBox.style.left = evt.xy.x+"px"; this.zoomBox.style.left = evt.xy.x+"px";
} }
@@ -124,20 +126,7 @@ OpenLayers.Control.MouseDefaults.prototype =
defaultMouseUp: function (evt) { defaultMouseUp: function (evt) {
if (!Event.isLeftClick(evt)) return; if (!Event.isLeftClick(evt)) return;
if (this.zoomBox) { if (this.zoomBox) {
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart ); this.zoomBoxEnd(evt);
var end = this.map.getLonLatFromViewPortPx( evt.xy );
var top = Math.max(start.lat, end.lat);
var bottom = Math.min(start.lat, end.lat);
var left = Math.min(start.lon, end.lon);
var right = Math.max(start.lon, end.lon);
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
var zoom = this.map.getZoomForExtent(bounds);
this.map.setCenter(new OpenLayers.LonLat(
(start.lon + end.lon) / 2,
(start.lat + end.lat) / 2
), zoom);
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
this.zoomBox = null;
} else { } else {
if (this.performedDrag) { if (this.performedDrag) {
this.map.setCenter(this.map.center); this.map.setCenter(this.map.center);
@@ -173,6 +162,37 @@ OpenLayers.Control.MouseDefaults.prototype =
this.map.zoomOut(); this.map.zoomOut();
}, },
/** Zoombox function.
*
*/
zoomBoxEnd: function(evt) {
if (this.mouseDragStart != null) {
if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 ||
Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) {
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
var end = this.map.getLonLatFromViewPortPx( evt.xy );
var top = Math.max(start.lat, end.lat);
var bottom = Math.min(start.lat, end.lat);
var left = Math.min(start.lon, end.lon);
var right = Math.max(start.lon, end.lon);
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
var zoom = this.map.getZoomForExtent(bounds);
this.map.setCenter(new OpenLayers.LonLat(
(start.lon + end.lon) / 2,
(start.lat + end.lat) / 2
), zoom);
} else {
var end = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(new OpenLayers.LonLat(
(end.lon),
(end.lat)
), this.map.getZoom() + 1);
}
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
this.zoomBox = null;
}
},
/** /**
* Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/ * Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/
+17 -22
View File
@@ -6,12 +6,14 @@
* @class * @class
* *
* @requires OpenLayers/Control.js * @requires OpenLayers/Control.js
* @requires OpenLayers/Control/MouseDefaults.js
*/ */
OpenLayers.Control.MouseToolbar = Class.create(); OpenLayers.Control.MouseToolbar = Class.create();
OpenLayers.Control.MouseToolbar.X = 6; OpenLayers.Control.MouseToolbar.X = 6;
OpenLayers.Control.MouseToolbar.Y = 300; OpenLayers.Control.MouseToolbar.Y = 300;
OpenLayers.Control.MouseToolbar.prototype = OpenLayers.Control.MouseToolbar.prototype =
Object.extend( new OpenLayers.Control(), { Object.extend( new OpenLayers.Control(),
Object.extend( new OpenLayers.Control.MouseDefaults(), {
mode: null, mode: null,
@@ -47,9 +49,7 @@ OpenLayers.Control.MouseToolbar.prototype =
centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0)); centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
this._addButton("pan", "panning-hand-off.png", "panning-hand-on.png", centered, sz, "Drag the map to pan."); this._addButton("pan", "panning-hand-off.png", "panning-hand-on.png", centered, sz, "Drag the map to pan.");
centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0)); centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
this._addButton("measure", "measuring-stick-off.png", "measuring-stick-on.png", centered, sz, "Hold alt when clicking to show distance between selected points");
this.switchModeTo("pan"); this.switchModeTo("pan");
this.map.events.register("zoomend", this, function() { this.switchModeTo("pan"); });
return this.div; return this.div;
}, },
@@ -95,6 +95,8 @@ OpenLayers.Control.MouseToolbar.prototype =
this.performedDrag = false; this.performedDrag = false;
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(newCenter, this.map.zoom + 2); this.map.setCenter(newCenter, this.map.zoom + 2);
Event.stop(evt);
return false;
}, },
/** /**
@@ -104,8 +106,10 @@ OpenLayers.Control.MouseToolbar.prototype =
if (!Event.isLeftClick(evt)) return; if (!Event.isLeftClick(evt)) return;
this.mouseDragStart = evt.xy.clone(); this.mouseDragStart = evt.xy.clone();
this.performedDrag = false; this.performedDrag = false;
this.startViaKeyboard = false;
if (evt.shiftKey && this.mode !="zoombox") { if (evt.shiftKey && this.mode !="zoombox") {
this.switchModeTo("zoombox"); this.switchModeTo("zoombox");
this.startViaKeyboard = true;
} else if (evt.altKey && this.mode !="measure") { } else if (evt.altKey && this.mode !="measure") {
this.switchModeTo("measure"); this.switchModeTo("measure");
} else if (!this.mode) { } else if (!this.mode) {
@@ -124,8 +128,10 @@ OpenLayers.Control.MouseToolbar.prototype =
this.zoomBox.style.backgroundColor = "white"; this.zoomBox.style.backgroundColor = "white";
this.zoomBox.style.filter = "alpha(opacity=50)"; // IE this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
this.zoomBox.style.opacity = "0.50"; this.zoomBox.style.opacity = "0.50";
this.zoomBox.style.fontSize = "1px";
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
this.map.viewPortDiv.appendChild(this.zoomBox); this.map.viewPortDiv.appendChild(this.zoomBox);
this.performedDrag = true;
break; break;
case "measure": case "measure":
var distance = ""; var distance = "";
@@ -178,7 +184,7 @@ OpenLayers.Control.MouseToolbar.prototype =
switchModeTo: function(mode) { switchModeTo: function(mode) {
if (mode != this.mode) { if (mode != this.mode) {
if (this.mode) { if (this.mode && this.buttons[this.mode]) {
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation); OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation);
} }
if (this.mode == "measure" && mode != "measure") { if (this.mode == "measure" && mode != "measure") {
@@ -191,8 +197,10 @@ OpenLayers.Control.MouseToolbar.prototype =
this.measureStart = null; this.measureStart = null;
} }
this.mode = mode; this.mode = mode;
if (this.buttons[mode]) {
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation); OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation);
} }
}
}, },
leaveMode: function() { leaveMode: function() {
@@ -208,8 +216,8 @@ OpenLayers.Control.MouseToolbar.prototype =
case "zoombox": case "zoombox":
var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x); var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y); var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);
this.zoomBox.style.width = deltaX+"px"; this.zoomBox.style.width = Math.max(1, deltaX) + "px";
this.zoomBox.style.height = deltaY+"px"; this.zoomBox.style.height = Math.max(1, deltaY) + "px";
if (evt.xy.x < this.mouseDragStart.x) { if (evt.xy.x < this.mouseDragStart.x) {
this.zoomBox.style.left = evt.xy.x+"px"; this.zoomBox.style.left = evt.xy.x+"px";
} }
@@ -238,21 +246,8 @@ OpenLayers.Control.MouseToolbar.prototype =
if (!Event.isLeftClick(evt)) return; if (!Event.isLeftClick(evt)) return;
switch (this.mode) { switch (this.mode) {
case "zoombox": case "zoombox":
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart ); this.zoomBoxEnd(evt);
var end = this.map.getLonLatFromViewPortPx( evt.xy ); if (this.startViaKeyboard) this.leaveMode();
var top = Math.max(start.lat, end.lat);
var bottom = Math.min(start.lat, end.lat);
var left = Math.min(start.lon, end.lon);
var right = Math.max(start.lon, end.lon);
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
var zoom = this.map.getZoomForExtent(bounds);
this.map.setCenter(new OpenLayers.LonLat(
(start.lon + end.lon) / 2,
(start.lat + end.lat) / 2
), zoom);
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
this.zoomBox = null;
this.leaveMode();
break; break;
case "pan": case "pan":
if (this.performedDrag) { if (this.performedDrag) {
@@ -276,5 +271,5 @@ OpenLayers.Control.MouseToolbar.prototype =
return false; return false;
} }
} }
}); }));
+1 -1
View File
@@ -184,8 +184,8 @@ OpenLayers.Control.PanZoomBar.prototype =
this.slider.style.top = newTop+"px"; this.slider.style.top = newTop+"px";
} }
this.mouseDragStart = evt.xy.clone(); this.mouseDragStart = evt.xy.clone();
}
Event.stop(evt); Event.stop(evt);
}
}, },
/* /*
+3
View File
@@ -182,6 +182,9 @@ OpenLayers.Layer.prototype = {
'minExtent', 'maxExtent', 'minExtent', 'maxExtent',
'numZoomLevels' 'numZoomLevels'
); );
if (this.map.maxZoomLevel && !this.numZoomLevels) {
this.numZoomLevels = this.map.maxZoomLevel + 1;
}
for(var i=0; i < properties.length; i++) { for(var i=0; i < properties.length; i++) {
if (this[properties[i]] == null) { if (this[properties[i]] == null) {
this[properties[i]] = this.map[properties[i]]; this[properties[i]] = this.map[properties[i]];
-1
View File
@@ -63,7 +63,6 @@ OpenLayers.Layer.EventPane.prototype =
} else { } else {
this.map.layerContainerDiv.appendChild(this.pane); this.map.layerContainerDiv.appendChild(this.pane);
} }
this.map.events.attachToElement(this.pane);
}, },
/** /**
+1 -1
View File
@@ -49,7 +49,7 @@ OpenLayers.Layer.KaMap.prototype =
*/ */
getURL: function (bounds) { getURL: function (bounds) {
var mapRes = this.map.getResolution(); var mapRes = this.map.getResolution();
var scale = this.map.getScale(); var scale = Math.round((this.map.getScale() * 10000)) / 10000;
var cellSize = new OpenLayers.Size(mapRes*this.tileSize.w, mapRes*this.tileSize.h); var cellSize = new OpenLayers.Size(mapRes*this.tileSize.w, mapRes*this.tileSize.h);
var pX = Math.round(((bounds.left) / cellSize.w) * this.tileSize.w); var pX = Math.round(((bounds.left) / cellSize.w) * this.tileSize.w);
var pY = -Math.round(((bounds.top) / cellSize.h) * this.tileSize.h); var pY = -Math.round(((bounds.top) / cellSize.h) * this.tileSize.h);
+4 -2
View File
@@ -371,9 +371,12 @@ OpenLayers.Map.prototype = {
if (center != null) { if (center != null) {
var zoom = this.getZoom(); var zoom = this.getZoom();
this.zoom = null; this.zoom = null;
this.setCenter(center, zoom); if (zoom > this.baseLayer.numZoomLevels - 1) {
zoom = this.baseLayer.numZoomLevels - 1;
} }
this.setCenter(center, zoom);
}
if ((noEvent == null) || (noEvent == false)) { if ((noEvent == null) || (noEvent == false)) {
this.events.triggerEvent("changebaselayer"); this.events.triggerEvent("changebaselayer");
} }
@@ -562,7 +565,6 @@ OpenLayers.Map.prototype = {
* trigger movestart/end events * trigger movestart/end events
*/ */
setCenter: function (lonlat, zoom, minor) { setCenter: function (lonlat, zoom, minor) {
var zoomChanged = (this.isValidZoomLevel(zoom)) && var zoomChanged = (this.isValidZoomLevel(zoom)) &&
(zoom != this.getZoom()); (zoom != this.getZoom());
+1
View File
@@ -22,6 +22,7 @@
<li>test_Tile.html</li> <li>test_Tile.html</li>
<li>test_Tile_Image.html</li> <li>test_Tile_Image.html</li>
<li>test_Control.html</li> <li>test_Control.html</li>
<li>test_Control_MouseToolbar.html</li>
<li>test_Control_LayerSwitcher.html</li> <li>test_Control_LayerSwitcher.html</li>
<li>test_Control_PanZoom.html</li> <li>test_Control_PanZoom.html</li>
<li>test_Control_PanZoomBar.html</li> <li>test_Control_PanZoomBar.html</li>
+55
View File
@@ -0,0 +1,55 @@
<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
var map;
function test_01_Control_MouseToolbar_constructor (t) {
t.plan( 1 );
control = new OpenLayers.Control.MouseToolbar();
t.ok( control instanceof OpenLayers.Control.MouseToolbar, "new OpenLayers.Control.MouseToolbar returns object" );
}
function test_02_Control_MouseToolbar_addControl (t) {
t.plan( 7 );
map = new OpenLayers.Map('map');
control = new OpenLayers.Control.MouseToolbar();
t.ok( control instanceof OpenLayers.Control.MouseToolbar, "new OpenLayers.Control.MouseToolbar returns object" );
t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" );
map.addControl(control);
t.ok( control.map === map, "Control.map is set to the map object" );
t.ok( map.controls[2] === control, "map.controls contains control" );
t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 3, "Control div zIndexed properly" );
t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 3, "Viewport div contains control div" );
t.eq( control.div.style.top, "6px", "Control div top located correctly by default");
}
function test_03_Control_MouseToolbar_control_events (t) {
t.plan( 1 );
var evt = {which: 1}; // control expects left-click
map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS("Test Layer",
"http://octo.metacarta.com/cgi-bin/mapserv?",
{map: "/mapdata/vmap_wms.map", layers: "basic"});
map.addLayer(layer);
control = new OpenLayers.Control.MouseToolbar();
map.addControl(control);
var centerLL = new OpenLayers.LonLat(0,0);
map.setCenter(centerLL, 5);
evt.shiftKey = true;
evt.xy = new OpenLayers.Size(5,5);
control.defaultMouseDown(evt);
evt.xy = new OpenLayers.Size(15,15);
control.defaultMouseUp(evt);
t.eq(map.getZoom(), 5, "Map zoom set correctly after zoombox");
}
// -->
</script>
</head>
<body>
<div id="map" style="width: 1024px; height: 512px;"/>
</body>
</html>