Compare commits

...

10 Commits

Author SHA1 Message Date
crschmidt 539df55c39 RC3 had a major bug with event handling in the MouseToolbar, introduced due
to firebug/safari-specific debug statements left in the RC. This will fix the
"Every time I drag a rectangle, it just keeps dragging" issue that users
were reporting.


git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.0-rc4@1349 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-08-24 05:14:46 +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
8 changed files with 43 additions and 30 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

+17 -12
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;
}, },
/** /**
@@ -124,20 +125,24 @@ 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 ); if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 ||
var end = this.map.getLonLatFromViewPortPx( evt.xy ); Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) {
var top = Math.max(start.lat, end.lat); var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
var bottom = Math.min(start.lat, end.lat); var end = this.map.getLonLatFromViewPortPx( evt.xy );
var left = Math.min(start.lon, end.lon); var top = Math.max(start.lat, end.lat);
var right = Math.max(start.lon, end.lon); var bottom = Math.min(start.lat, end.lat);
var bounds = new OpenLayers.Bounds(left, bottom, right, top); var left = Math.min(start.lon, end.lon);
var zoom = this.map.getZoomForExtent(bounds); var right = Math.max(start.lon, end.lon);
this.map.setCenter(new OpenLayers.LonLat( var bounds = new OpenLayers.Bounds(left, bottom, right, top);
(start.lon + end.lon) / 2, var zoom = this.map.getZoomForExtent(bounds);
(start.lat + end.lat) / 2 this.map.setCenter(new OpenLayers.LonLat(
), zoom); (start.lon + end.lon) / 2,
(start.lat + end.lat) / 2
), zoom);
}
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox")); this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
this.zoomBox = null; this.zoomBox = null;
} else { } else {
if (this.performedDrag) { if (this.performedDrag) {
this.map.setCenter(this.map.center); this.map.setCenter(this.map.center);
+21 -15
View File
@@ -47,9 +47,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 +93,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 +104,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) {
@@ -238,21 +240,25 @@ 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 ); if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 ||
var end = this.map.getLonLatFromViewPortPx( evt.xy ); Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) {
var top = Math.max(start.lat, end.lat); var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
var bottom = Math.min(start.lat, end.lat); var end = this.map.getLonLatFromViewPortPx( evt.xy );
var left = Math.min(start.lon, end.lon); var top = Math.max(start.lat, end.lat);
var right = Math.max(start.lon, end.lon); var bottom = Math.min(start.lat, end.lat);
var bounds = new OpenLayers.Bounds(left, bottom, right, top); var left = Math.min(start.lon, end.lon);
var zoom = this.map.getZoomForExtent(bounds); var right = Math.max(start.lon, end.lon);
this.map.setCenter(new OpenLayers.LonLat( var bounds = new OpenLayers.Bounds(left, bottom, right, top);
(start.lon + end.lon) / 2, var zoom = this.map.getZoomForExtent(bounds);
(start.lat + end.lat) / 2 this.map.setCenter(new OpenLayers.LonLat(
), zoom); (start.lon + end.lon) / 2,
(start.lat + end.lat) / 2
), zoom);
}
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox")); this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
this.zoomBox = null; this.zoomBox = null;
this.leaveMode(); console.log(this.startViaKeyboard);
if (this.startViaKeyboard) this.leaveMode();
break; break;
case "pan": case "pan":
if (this.performedDrag) { if (this.performedDrag) {
+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);