Changeset 5797
- Timestamp:
- 01/17/08 11:37:26 (1 year ago)
- Files:
-
- sandbox/enjahova/openlayers/examples/more-controls.html (modified) (3 diffs)
- sandbox/enjahova/openlayers/lib/OpenLayers.js (modified) (1 diff)
- sandbox/enjahova/openlayers/lib/OpenLayers/Control/Identify.js (modified) (3 diffs)
- sandbox/enjahova/openlayers/lib/OpenLayers/Control/Switch.js (modified) (5 diffs)
- sandbox/enjahova/openlayers/lib/OpenLayers/Control/ZoomOut.js (modified) (3 diffs)
- sandbox/enjahova/openlayers/lib/OpenLayers/Map.js (modified) (3 diffs)
- sandbox/enjahova/openlayers/tests/Control/test_Switch.html (added)
- sandbox/enjahova/openlayers/tests/list-tests.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/enjahova/openlayers/examples/more-controls.html
r5378 r5797 16 16 <title>More Controls Demo</title> 17 17 <script src="../lib/OpenLayers.js"></script> 18 <script type="text/javascript" src="../lib/openlayers/lib/OpenLayers/Control/ZoomOut.js"></script> 19 <script type="text/javascript" src="../lib/openlayers/lib/OpenLayers/Control/Identify.js"></script> 20 <script type="text/javascript" src="../lib/openlayers/lib/OpenLayers/Control/Switch.js"></script> 18 21 <script type="text/javascript"> 19 22 var lon = 5; … … 24 27 function identify(pos) 25 28 { 26 alert("user identify: pos = (" + pos.lat + ", " + pos.lon + ")"); 29 alert("user identify: pos = (" + pos.x + ", " + pos.y + ")"); 30 } 31 32 function on() 33 { 34 alert("user turned switch on"); 35 } 36 37 function off() 38 { 39 alert("user turned switch off"); 27 40 } 28 41 29 42 function init() { 30 43 var nt = new OpenLayers.Control.NavToolbar({'div':OpenLayers.Util.getElement('paneldiv')}); 31 nt.addControls(new OpenLayers.Control.ZoomOut()) 32 nt.addControls(new OpenLayers.Control.ZoomToMaxExtent()) 33 nt.addControls(new OpenLayers.Control.ZoomToLastExtent()) 34 nt.addControls(new OpenLayers.Control.Identify(identify)) 44 nt.addControls(new OpenLayers.Control.ZoomOut()); 45 nt.addControls(new OpenLayers.Control.Identify(identify)); 46 nt.addControls(new OpenLayers.Control.Switch(on,off)); 35 47 map = new OpenLayers.Map('map', { controls: [nt], theme: null }); 36 48 … … 46 58 <h3 id="title">More Controls Demo</h3> 47 59 <p id="shortdesc"> 48 Demo the ZoomOut, ZoomToLastExtent, and IdentifyControls.60 Demo the ZoomOut, Identify and Switch Controls. 49 61 (Using modified famfamfam.com icons) 50 62 </p> sandbox/enjahova/openlayers/lib/OpenLayers.js
r5787 r5797 131 131 "OpenLayers/Control/ZoomBox.js", 132 132 "OpenLayers/Control/Identify.js", 133 "OpenLayers/Control/Email.js",134 133 "OpenLayers/Control/ZoomOut.js", 135 134 "OpenLayers/Control/ZoomToMaxExtent.js", 136 "OpenLayers/Control/ZoomToLastExtent.js",137 135 "OpenLayers/Control/DragPan.js", 138 136 "OpenLayers/Control/Navigation.js", sandbox/enjahova/openlayers/lib/OpenLayers/Control/Identify.js
r5497 r5797 5 5 /** 6 6 * @requires OpenLayers/Control.js 7 * @requires OpenLayers/Handler/ Drag.js7 * @requires OpenLayers/Handler/Click.js 8 8 * 9 9 * Class: OpenLayers.Control.Identify … … 24 24 * 25 25 * Parameters: 26 * options - { func} An optional object whose properties will be used26 * options - {userFunction} An optional object whose properties will be used 27 27 * to extend the control. 28 28 */ 29 initialize: function( func, options) {29 initialize: function(userFunction, options) { 30 30 OpenLayers.Control.prototype.initialize.apply(this, [options]); 31 this.userFunc tion = func;31 this.userFunc = userFunction; 32 32 }, 33 33 … … 37 37 */ 38 38 draw: function() { 39 this.handler = new OpenLayers.Handler. Drag( this,40 {"up": this.identify}, {keyMask: this.keyMask} );39 this.handler = new OpenLayers.Handler.Click( this, 40 {"click": this.identify}, {keyMask: this.keyMask} ); 41 41 }, 42 42 43 43 /** 44 44 * Method: identify 45 * Placeholder for user defined identify function 45 46 * 46 47 * Parameters: 47 * position - {<OpenLayers.Pixel>} 48 * evt - {Click Event} 49 * 48 50 */ 49 identify: function ( position) {50 //var pos = this.map.getLonLatFromPixel(position)51 this.userFunc tion(position);51 identify: function (evt) { 52 var position = evt.xy; 53 this.userFunc(position); 52 54 }, 53 55 54 /**55 * Method: userFunction56 * placeholder for the userdefined function that will handle the identify57 */58 userFunction: function(pos){59 },60 61 56 CLASS_NAME: "OpenLayers.Control.Identify" 62 57 }); sandbox/enjahova/openlayers/lib/OpenLayers/Control/Switch.js
r5787 r5797 5 5 /** 6 6 * @requires OpenLayers/Control.js 7 * @requires OpenLayers/Handler/Drag.js8 7 * 9 * Class: OpenLayers.Control. Identify8 * Class: OpenLayers.Control.Switch 10 9 * 11 10 * Inherits from: … … 20 19 21 20 /** 22 * Constructor: OpenLayers.Control. Identify23 * Fires a user defined function w ith the mouse position21 * Constructor: OpenLayers.Control.Switch 22 * Fires a user defined function when toggled on/off 24 23 * 25 24 * Parameters: … … 32 31 this.userOff = off; 33 32 }, 34 33 34 /** 35 * Method: activate 36 * Override OpenLayers.Control.activate to call user defined "on" function 37 */ 35 38 activate: function () { 36 39 if (this.active) { … … 45 48 }, 46 49 50 /** 51 * Method: deactivate 52 * Override OpenLayers.Control.deactivate to call user defined "off" function 53 */ 47 54 deactivate: function () { 48 55 if (this.active) { … … 59 66 60 67 /** 61 * Method: user Function62 * placeholder for the user defined function that will handle the identify68 * Method: userOn 69 * placeholder for the user defined function that will be fired when Switch is activated 63 70 */ 64 71 userOn: function(){ 65 72 }, 66 73 /** 74 * Method: userOn 75 * placeholder for the user defined function that will be fired when Switch is activated 76 */ 67 77 userOff: function(){ 68 78 }, sandbox/enjahova/openlayers/lib/OpenLayers/Control/ZoomOut.js
r5374 r5797 5 5 /** 6 6 * @requires OpenLayers/Control.js 7 * @requires OpenLayers/Handler/ Box.js7 * @requires OpenLayers/Handler/Click.js 8 8 * 9 * Class: OpenLayers.Control.Zoom In9 * Class: OpenLayers.Control.ZoomOut 10 10 * 11 11 * Inherits from: … … 23 23 */ 24 24 draw: function() { 25 this.handler = new OpenLayers.Handler. Drag( this,26 {" down": this.zoomOut}, {keyMask: this.keyMask} );25 this.handler = new OpenLayers.Handler.Click( this, 26 {"click": this.zoomOut}, {keyMask: this.keyMask} ); 27 27 }, 28 28 … … 31 31 * 32 32 * Parameters: 33 * position - {<OpenLayers.Pixel>}33 * evt - {<Click Event>} 34 34 */ 35 zoomOut: function (position) { 35 zoomOut: function (evt) { 36 var position = evt.xy; 36 37 this.map.setCenter(this.map.getLonLatFromPixel(position), 37 38 this.map.getZoom() - 1); sandbox/enjahova/openlayers/lib/OpenLayers/Map.js
r5719 r5797 142 142 */ 143 143 viewRequestID: 0, 144 145 /**146 * Property extents147 * {Array} Used to store a history of the extents148 */149 extents: [],150 144 151 145 // Options … … 400 394 OpenLayers.Event.observe(window, 'unload', this.unloadDestroy); 401 395 402 //keep track of previous extents so we can "undo" them Used by ZoomToLastExtent403 var func = function () {404 //console.log(this.getExtent());405 //console.log(this.getScale());406 this.extents.push(this.getExtent());407 }408 this.events.register("moveend", map, func );409 396 }, 410 397 … … 1697 1684 }, 1698 1685 1699 /**1700 * APIMethod: zoomToLastExtent1701 * Zoom to the full extent and recenter.1702 */1703 zoomToLastExtent: function() {1704 //maybe not the cleanest way to do this (no 'redo') but it works1705 if(this.extents.length > 1)1706 {1707 var tmp = this.extents.pop();1708 var last_extent = this.extents.pop();1709 this.zoomToExtent(last_extent);1710 }1711 else1712 {1713 this.zoomToMaxExtent();1714 this.extents.pop();this.extents.pop();//original extent should leave extents empty1715 }1716 },1717 1718 1686 /** 1719 1687 * APIMethod: zoomToScale sandbox/enjahova/openlayers/tests/list-tests.html
r5719 r5797 89 89 <li>Control/test_Identify.html</li> 90 90 <li>Control/test_SelectFeature.html</li> 91 <li>Control/test_Switch.html</li> 91 92 <li>test_Handler.html</li> 92 93 <li>Handler/test_Click.html</li>
