Changeset 1338
- Timestamp:
- 08/23/06 16:37:16 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/openlayers/2.0/lib/OpenLayers/Control/MouseDefaults.js
r1248 r1338 61 61 this.map.setCenter(newCenter, this.map.zoom + 1); 62 62 Event.stop(evt); 63 return false; 63 64 }, 64 65 … … 125 126 if (!Event.isLeftClick(evt)) return; 126 127 if (this.zoomBox) { 127 var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart ); 128 var end = this.map.getLonLatFromViewPortPx( evt.xy ); 129 var top = Math.max(start.lat, end.lat); 130 var bottom = Math.min(start.lat, end.lat); 131 var left = Math.min(start.lon, end.lon); 132 var right = Math.max(start.lon, end.lon); 133 var bounds = new OpenLayers.Bounds(left, bottom, right, top); 134 var zoom = this.map.getZoomForExtent(bounds); 135 this.map.setCenter(new OpenLayers.LonLat( 136 (start.lon + end.lon) / 2, 137 (start.lat + end.lat) / 2 138 ), zoom); 128 if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 || 129 Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) { 130 var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart ); 131 var end = this.map.getLonLatFromViewPortPx( evt.xy ); 132 var top = Math.max(start.lat, end.lat); 133 var bottom = Math.min(start.lat, end.lat); 134 var left = Math.min(start.lon, end.lon); 135 var right = Math.max(start.lon, end.lon); 136 var bounds = new OpenLayers.Bounds(left, bottom, right, top); 137 var zoom = this.map.getZoomForExtent(bounds); 138 this.map.setCenter(new OpenLayers.LonLat( 139 (start.lon + end.lon) / 2, 140 (start.lat + end.lat) / 2 141 ), zoom); 142 } 139 143 this.map.viewPortDiv.removeChild(document.getElementById("zoomBox")); 140 144 this.zoomBox = null; 145 141 146 } else { 142 147 if (this.performedDrag) { branches/openlayers/2.0/lib/OpenLayers/Control/MouseToolbar.js
r1316 r1338 96 96 var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); 97 97 this.map.setCenter(newCenter, this.map.zoom + 2); 98 Event.stop(evt); 99 return false; 98 100 }, 99 101 … … 239 241 switch (this.mode) { 240 242 case "zoombox": 241 var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart ); 242 var end = this.map.getLonLatFromViewPortPx( evt.xy ); 243 var top = Math.max(start.lat, end.lat); 244 var bottom = Math.min(start.lat, end.lat); 245 var left = Math.min(start.lon, end.lon); 246 var right = Math.max(start.lon, end.lon); 247 var bounds = new OpenLayers.Bounds(left, bottom, right, top); 248 var zoom = this.map.getZoomForExtent(bounds); 249 this.map.setCenter(new OpenLayers.LonLat( 250 (start.lon + end.lon) / 2, 251 (start.lat + end.lat) / 2 252 ), zoom); 243 console.log(this.mouseDragStart, evt.xy); 244 console.log(Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 || Math.abs((this.mouseDragStart.y - evt.xy.y)) > 5); 245 console.log(Math.abs(this.mouseDragStart.x-evt.xy.x) > 5); 246 console.log(Math.abs(this.mouseDragStart.y-evt.xy.y)>5); 247 if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 || 248 Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) { 249 var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart ); 250 var end = this.map.getLonLatFromViewPortPx( evt.xy ); 251 var top = Math.max(start.lat, end.lat); 252 var bottom = Math.min(start.lat, end.lat); 253 var left = Math.min(start.lon, end.lon); 254 var right = Math.max(start.lon, end.lon); 255 var bounds = new OpenLayers.Bounds(left, bottom, right, top); 256 var zoom = this.map.getZoomForExtent(bounds); 257 this.map.setCenter(new OpenLayers.LonLat( 258 (start.lon + end.lon) / 2, 259 (start.lat + end.lat) / 2 260 ), zoom); 261 } 253 262 this.map.viewPortDiv.removeChild(document.getElementById("zoomBox")); 254 263 this.zoomBox = null;
