Changeset 6326
- Timestamp:
- 02/19/08 16:14:59 (11 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/enjahova/openlayers/lib/OpenLayers/Control/OverviewMap.js
r6232 r6326 38 38 * class name olControlOverviewMapElement) may have padding or other style 39 39 * attributes added via CSS. 40 size: new OpenLayers.Size(190,90)...leave blank so overview map width / height can be overwritten in css 41 */ 42 size: new OpenLayers.Size(), 40 */ 41 size: new OpenLayers.Size(180, 90), 43 42 44 43 /** … … 100 99 101 100 /** 102 * Property: dragHandler103 * { <OpenLayers.Handler.Drag>} A handler for dragging the extent rectangle.104 */ 105 dragHandler: null,101 * Property: handlers 102 * {Object} 103 */ 104 handlers: null, 106 105 107 106 /** … … 116 115 initialize: function(options) { 117 116 this.layers = []; 117 this.handlers = {}; 118 118 OpenLayers.Control.prototype.initialize.apply(this, [options]); 119 119 }, … … 127 127 return; 128 128 } 129 this.dragHandler.destroy(); 130 this.clickHandler.destroy(); 129 this.handlers.click.destroy(); 131 130 132 131 this.mapDiv.removeChild(this.extentRectangle); … … 156 155 } 157 156 158 this.map.events.unregister('moveend', this, this.update);157 this.map.events.unregister('moveend', this, this.update); 159 158 this.map.events.unregister("changebaselayer", this, 160 159 this.baseLayerDraw); … … 200 199 201 200 this.div.appendChild(this.element); 202 203 this.map.events.register('moveend', this, this.update);204 201 205 202 // Optionally add min/max buttons if the control will go in the … … 261 258 this.update(); 262 259 } 260 261 this.map.events.register('moveend', this, this.update); 262 263 263 return this.div; 264 264 }, … … 281 281 */ 282 282 rectDrag: function(px) { 283 var deltaX = this. dragHandler.last.x - px.x;284 var deltaY = this. dragHandler.last.y - px.y;283 var deltaX = this.handlers.drag.last.x - px.x; 284 var deltaY = this.handlers.drag.last.y - px.y; 285 285 if(deltaX != 0 || deltaY != 0) { 286 286 var rectTop = this.rectPxBounds.top; … … 435 435 // create the overview map 436 436 var options = OpenLayers.Util.extend( 437 {controls: [], maxResolution: 'auto'}, this.mapOptions); 437 {controls: [], maxResolution: 'auto', 438 fallThrough: false}, this.mapOptions); 438 439 this.ovmap = new OpenLayers.Map(this.mapDiv, options); 440 441 // prevent ovmap from being destroyed when the page unloads, because 442 // the OverviewMap control has to do this (and does it). 443 OpenLayers.Event.stopObserving(window, 'unload', this.ovmap.unloadDestroy); 444 439 445 this.ovmap.addLayers(this.layers); 440 446 this.ovmap.zoomToMaxExtent(); … … 451 457 this.hComp = (this.hComp) ? this.hComp : 2; 452 458 453 this. dragHandler= new OpenLayers.Handler.Drag(459 this.handlers.drag = new OpenLayers.Handler.Drag( 454 460 this, {move: this.rectDrag, done: this.updateMapToRect}, 455 461 {map: this.ovmap} 456 462 ); 457 this. clickHandler= new OpenLayers.Handler.Click(463 this.handlers.click = new OpenLayers.Handler.Click( 458 464 this, { 459 465 "click": this.mapDivClick … … 465 471 } 466 472 ); 467 this. clickHandler.activate();473 this.handlers.click.activate(); 468 474 469 475 this.rectEvents = new OpenLayers.Events(this, this.extentRectangle, 470 476 null, true); 471 477 this.rectEvents.register("mouseover", this, function(e) { 472 if(!this.dragHandler.active && !this.map.dragging) { 473 // this click handler de/activation can be removed when 474 // ticket #1247 is addressed 475 this.clickHandler.deactivate(); 476 this.dragHandler.activate(); 477 this.clickHandler.activate(); 478 if(!this.handlers.drag.active && !this.map.dragging) { 479 this.handlers.drag.activate(); 478 480 } 479 481 }); 480 482 this.rectEvents.register("mouseout", this, function(e) { 481 if(!this. dragHandler.dragging) {482 this. dragHandler.deactivate();483 if(!this.handlers.drag.dragging) { 484 this.handlers.drag.deactivate(); 483 485 } 484 486 }); … … 495 497 if(this.map.units != 'degrees') { 496 498 if(this.ovmap.getProjection() && (this.map.getProjection() != this.ovmap.getProjection())) { 497 alert( 'The overview map only works when it is in the same projection as the main map');499 alert(OpenLayers.i18n("sameProjection")); 498 500 } 499 501 } … … 510 512 updateMapToRect: function() { 511 513 var lonLatBounds = this.getMapBoundsFromRectBounds(this.rectPxBounds); 512 this.map.setCenter(lonLatBounds.getCenterLonLat(), this.map.zoom);514 this.map.setCenter(lonLatBounds.getCenterLonLat(), this.map.zoom); 513 515 }, 514 516
