Compare commits

..

1 Commits

Author SHA1 Message Date
crschmidt
ba42a3a1b5 Never do release management at 1:30 in the morning. (I apologize.)
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.0-rc5@1351 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 05:20:22 +00:00
6 changed files with 47 additions and 110 deletions

View File

@@ -81,7 +81,6 @@ OpenLayers.Control.MouseDefaults.prototype =
this.zoomBox.style.backgroundColor = "white";
this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
this.zoomBox.style.opacity = "0.50";
this.zoomBox.style.fontSize = "1px";
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
this.map.viewPortDiv.appendChild(this.zoomBox);
}
@@ -97,8 +96,8 @@ OpenLayers.Control.MouseDefaults.prototype =
if (this.zoomBox) {
var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);
this.zoomBox.style.width = Math.max(1, deltaX) + "px";
this.zoomBox.style.height = Math.max(1, deltaY) + "px";
this.zoomBox.style.width = deltaX+"px";
this.zoomBox.style.height = deltaY+"px";
if (evt.xy.x < this.mouseDragStart.x) {
this.zoomBox.style.left = evt.xy.x+"px";
}
@@ -126,7 +125,24 @@ OpenLayers.Control.MouseDefaults.prototype =
defaultMouseUp: function (evt) {
if (!Event.isLeftClick(evt)) return;
if (this.zoomBox) {
this.zoomBoxEnd(evt);
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);
}
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
this.zoomBox = null;
} else {
if (this.performedDrag) {
this.map.setCenter(this.map.center);
@@ -162,37 +178,6 @@ OpenLayers.Control.MouseDefaults.prototype =
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/

View File

@@ -6,14 +6,12 @@
* @class
*
* @requires OpenLayers/Control.js
* @requires OpenLayers/Control/MouseDefaults.js
*/
OpenLayers.Control.MouseToolbar = Class.create();
OpenLayers.Control.MouseToolbar.X = 6;
OpenLayers.Control.MouseToolbar.Y = 300;
OpenLayers.Control.MouseToolbar.prototype =
Object.extend( new OpenLayers.Control(),
Object.extend( new OpenLayers.Control.MouseDefaults(), {
Object.extend( new OpenLayers.Control(), {
mode: null,
@@ -128,10 +126,8 @@ OpenLayers.Control.MouseToolbar.prototype =
this.zoomBox.style.backgroundColor = "white";
this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
this.zoomBox.style.opacity = "0.50";
this.zoomBox.style.fontSize = "1px";
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
this.map.viewPortDiv.appendChild(this.zoomBox);
this.performedDrag = true;
break;
case "measure":
var distance = "";
@@ -184,7 +180,7 @@ OpenLayers.Control.MouseToolbar.prototype =
switchModeTo: function(mode) {
if (mode != this.mode) {
if (this.mode && this.buttons[this.mode]) {
if (this.mode) {
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation);
}
if (this.mode == "measure" && mode != "measure") {
@@ -197,9 +193,7 @@ OpenLayers.Control.MouseToolbar.prototype =
this.measureStart = null;
}
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);
}
},
@@ -216,8 +210,8 @@ OpenLayers.Control.MouseToolbar.prototype =
case "zoombox":
var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);
this.zoomBox.style.width = Math.max(1, deltaX) + "px";
this.zoomBox.style.height = Math.max(1, deltaY) + "px";
this.zoomBox.style.width = deltaX+"px";
this.zoomBox.style.height = deltaY+"px";
if (evt.xy.x < this.mouseDragStart.x) {
this.zoomBox.style.left = evt.xy.x+"px";
}
@@ -246,7 +240,23 @@ OpenLayers.Control.MouseToolbar.prototype =
if (!Event.isLeftClick(evt)) return;
switch (this.mode) {
case "zoombox":
this.zoomBoxEnd(evt);
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);
}
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
this.zoomBox = null;
if (this.startViaKeyboard) this.leaveMode();
break;
case "pan":
@@ -271,5 +281,5 @@ OpenLayers.Control.MouseToolbar.prototype =
return false;
}
}
}));
});

View File

@@ -184,8 +184,8 @@ OpenLayers.Control.PanZoomBar.prototype =
this.slider.style.top = newTop+"px";
}
this.mouseDragStart = evt.xy.clone();
Event.stop(evt);
}
Event.stop(evt);
},
/*

View File

@@ -371,12 +371,9 @@ OpenLayers.Map.prototype = {
if (center != null) {
var zoom = this.getZoom();
this.zoom = null;
if (zoom > this.baseLayer.numZoomLevels - 1) {
zoom = this.baseLayer.numZoomLevels - 1;
}
this.setCenter(center, zoom);
}
if ((noEvent == null) || (noEvent == false)) {
this.events.triggerEvent("changebaselayer");
}
@@ -565,6 +562,7 @@ OpenLayers.Map.prototype = {
* trigger movestart/end events
*/
setCenter: function (lonlat, zoom, minor) {
var zoomChanged = (this.isValidZoomLevel(zoom)) &&
(zoom != this.getZoom());
@@ -601,7 +599,7 @@ OpenLayers.Map.prototype = {
this.popups[i].updatePosition();
}
}
//send the move call to the baselayer and all the overlays
var bounds = this.getExtent();
for (var i = 0; i < this.layers.length; i++) {

View File

@@ -22,7 +22,6 @@
<li>test_Tile.html</li>
<li>test_Tile_Image.html</li>
<li>test_Control.html</li>
<li>test_Control_MouseToolbar.html</li>
<li>test_Control_LayerSwitcher.html</li>
<li>test_Control_PanZoom.html</li>
<li>test_Control_PanZoomBar.html</li>

View File

@@ -1,55 +0,0 @@
<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>