Changeset 1096
- Timestamp:
- 08/08/06 14:20:24 (2 years ago)
- Files:
-
- trunk/openlayers/art/layer-switcher-maximize.svg (copied) (copied from sandbox/euzuro/layerswitcher/art/layer-switcher-maximize.svg)
- trunk/openlayers/art/layer-switcher-minimize.svg (copied) (copied from sandbox/euzuro/layerswitcher/art/layer-switcher-minimize.svg)
- trunk/openlayers/examples/LayerSwitcher.html (copied) (copied from sandbox/euzuro/layerswitcher/examples/LayerSwitcher.html)
- trunk/openlayers/examples/boxes.html (copied) (copied from sandbox/euzuro/layerswitcher/examples/boxes.html)
- trunk/openlayers/examples/google.html (modified) (4 diffs)
- trunk/openlayers/img/layer-switcher-minimize.png (modified) (previous)
- trunk/openlayers/lib/OpenLayers.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Control/LayerSwitcher.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Control/LayerTabs.js (copied) (copied from sandbox/euzuro/layerswitcher/lib/OpenLayers/Control/LayerTabs.js)
- trunk/openlayers/lib/OpenLayers/Control/MouseToolbar.js (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Icon.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer.js (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Boxes.js (copied) (copied from sandbox/euzuro/layerswitcher/lib/OpenLayers/Layer/Boxes.js)
- trunk/openlayers/lib/OpenLayers/Layer/GeoRSS.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Google.js (modified) (8 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Grid.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer/KaMap.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Markers.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Text.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/VirtualEarth.js (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/WFS.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/WMS.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/WMS/Untiled.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/WorldWind.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Yahoo.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Map.js (modified) (7 diffs)
- trunk/openlayers/lib/OpenLayers/Marker (copied) (copied from sandbox/euzuro/layerswitcher/lib/OpenLayers/Marker)
- trunk/openlayers/lib/OpenLayers/Marker.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Marker/Box.js (copied) (copied from sandbox/euzuro/layerswitcher/lib/OpenLayers/Marker/Box.js)
- trunk/openlayers/tests/list-tests.html (modified) (1 diff)
- trunk/openlayers/tests/run-tests.html (modified) (2 diffs)
- trunk/openlayers/tests/test_Bounds.html (modified) (2 diffs)
- trunk/openlayers/tests/test_Control_LayerSwitcher.html (copied) (copied from sandbox/euzuro/layerswitcher/tests/test_Control_LayerSwitcher.html)
- trunk/openlayers/tests/test_Layer.html (modified) (1 diff)
- trunk/openlayers/tests/test_Layer_Google.html (modified) (2 diffs)
- trunk/openlayers/tests/test_Layer_Grid.html (modified) (1 diff)
- trunk/openlayers/tests/test_Layer_KaMap.html (modified) (1 diff)
- trunk/openlayers/tests/test_Layer_WMS.html (modified) (1 diff)
- trunk/openlayers/tests/test_Map.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/examples/google.html
r915 r1096 23 23 function init(){ 24 24 map = new OpenLayers.Map( $('map') ); 25 gmap = new OpenLayers.Layer.Google( "Google" );25 gmap = new OpenLayers.Layer.Google( "Google" , {type: G_HYBRID_MAP }); 26 26 map.addLayer(gmap); 27 27 … … 31 31 map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); 32 32 map.addControl( new OpenLayers.Control.LayerSwitcher() ); 33 33 34 } 34 35 … … 42 43 markers.removeMarker(marker); 43 44 } 44 45 45 46 // --> 46 47 … … 50 51 <h1>OpenLayers With Google Layer Example</h1> 51 52 <div id="map"></div> 52 <div style="background-color:green" onclick="add()"> click to add the marker to the map</div>53 53 <div style="background-color:red" onclick="remove()"> click to remove the marker from the map</div> 54 54 </body> trunk/openlayers/lib/OpenLayers.js
r965 r1096 59 59 "OpenLayers/Icon.js", 60 60 "OpenLayers/Marker.js", 61 "OpenLayers/Marker/Box.js", 61 62 "OpenLayers/Popup.js", 62 63 "OpenLayers/Tile.js", … … 78 79 "OpenLayers/Layer/WMS/Untiled.js", 79 80 "OpenLayers/Layer/GeoRSS.js", 81 "OpenLayers/Layer/Boxes.js", 80 82 "OpenLayers/Popup/Anchored.js", 81 83 "OpenLayers/Popup/AnchoredBubble.js", … … 88 90 "OpenLayers/Control/Permalink.js", 89 91 "OpenLayers/Control/Scale.js", 90 "OpenLayers/Control/LayerSwitcher.js" 92 "OpenLayers/Control/LayerSwitcher.js", 93 "OpenLayers/Control/LayerTabs.js" 91 94 ); // etc. 92 95 trunk/openlayers/lib/OpenLayers/Control/LayerSwitcher.js
r1050 r1096 2 2 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full 3 3 * text of the license. */ 4 4 5 // @require: OpenLayers/Control.js 6 5 7 /** 6 8 * @class 7 9 */ 8 10 OpenLayers.Control.LayerSwitcher = Class.create(); 9 10 /** color used in the UI to show a layer is active/displayed11 *12 * @final13 * @type String14 */15 OpenLayers.Control.LayerSwitcher.ACTIVE_COLOR = "darkblue";16 17 /** color used in the UI to show a layer is deactivated/hidden18 *19 * @final20 * @type String21 */22 OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR = "lightblue";23 24 25 11 OpenLayers.Control.LayerSwitcher.prototype = 26 12 Object.extend( new OpenLayers.Control(), { 27 13 28 14 /** @type String */ 29 activeColor: "", 30 31 /** @type String */ 32 nonActiveColor: "", 33 34 /** @type String */ 35 mode: "checkbox", 36 15 activeColor: "darkblue", 16 17 18 // DOM Elements 19 20 /** @type DOMElement */ 21 layersDiv: null, 22 23 /** @type DOMElement */ 24 baseLayersDiv: null, 25 26 /** @type Array */ 27 baseLayerInputs: null, 28 29 /** @type DOMElement */ 30 dataLayersDiv: null, 31 32 /** @type Array */ 33 dataLayerInputs: null, 34 35 36 /** @type DOMElement */ 37 minimizeDiv: null, 38 39 /** @type DOMElement */ 40 maximizeDiv: null, 41 37 42 /** 38 43 * @constructor 39 44 */ 40 45 initialize: function(options) { 41 this.activeColor = OpenLayers.Control.LayerSwitcher.ACTIVE_COLOR;42 this.nonActiveColor = OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR;43 this.backdrops = [];44 46 OpenLayers.Control.prototype.initialize.apply(this, arguments); 47 }, 48 49 /** 50 * @param {OpenLayers.Map} map 51 */ 52 setMap: function(map) { 53 OpenLayers.Control.prototype.setMap.apply(this, arguments); 54 55 this.map.events.register("addlayer", this, this.redraw); 56 this.map.events.register("changelayer", this, this.redraw); 57 this.map.events.register("removelayer", this, this.redraw); 58 this.map.events.register("changebaselayer", this, this.redraw); 45 59 }, 46 60 … … 50 64 */ 51 65 draw: function() { 52 // initialize our internal div53 66 OpenLayers.Control.prototype.draw.apply(this); 54 67 68 // create layout divs 69 this.loadContents(); 70 71 // set mode to minimize 72 this.minimizeControl(); 73 74 // populate div with current info 75 this.redraw(); 76 77 return this.div; 78 }, 79 80 /** Goes through and takes the current state of the Map and rebuilds the 81 * control to display that state. Groups base layers into a radio-button 82 * group and lists each data layer with a checkbox. 83 * 84 * @returns A reference to the DIV DOMElement containing the control 85 * @type DOMElement 86 */ 87 redraw: function() { 88 89 //clear out previous layers 90 this.baseLayersDiv.innerHTML = ""; 91 this.baseLayerInputs = new Array(); 92 93 this.dataLayersDiv.innerHTML = ""; 94 this.dataLayerInputs = new Array(); 95 96 for( var i = 0; i < this.map.layers.length; i++) { 97 var layer = this.map.layers[i]; 98 var baseLayer = layer.isBaseLayer; 99 100 // only check a baselayer if it is *the* baselayer, check data 101 // layers if they are visible 102 var checked = (baseLayer) ? (layer == this.map.baseLayer) 103 : layer.getVisibility(); 104 105 // create input element 106 var inputElem = document.createElement("input"); 107 inputElem.id = "input_" + layer.name; 108 inputElem.name = (baseLayer) ? "baseLayers" : layer.name; 109 inputElem.type = (baseLayer) ? "radio" : "checkbox"; 110 inputElem.value = layer.name; 111 inputElem.checked = checked; 112 inputElem.layer = layer; 113 114 // create span 115 var labelSpan = document.createElement("span"); 116 labelSpan.innerHTML = layer.name; 117 labelSpan.style.verticalAlign = (baseLayer) ? "bottom" : "auto"; 118 Event.observe(labelSpan, 119 "click", 120 this.onLabelClick.bindAsEventListener(inputElem)); 121 122 // create line break 123 var br = document.createElement("br"); 124 125 126 var groupArray = (baseLayer) ? this.baseLayerInputs 127 : this.dataLayerInputs; 128 groupArray.push(inputElem); 129 130 131 var groupDiv = (baseLayer) ? this.baseLayersDiv 132 : this.dataLayersDiv; 133 groupDiv.appendChild(inputElem); 134 groupDiv.appendChild(labelSpan); 135 groupDiv.appendChild(br); 136 137 } 138 139 return this.div; 140 }, 141 142 /** A label has been clicked, check or uncheck its corresponding input 143 * 144 * @private 145 * 146 * @param {Event} e 147 */ 148 onLabelClick: function(e) { 149 this.checked = !this.checked; 150 }, 151 152 /** Need to update the map accordingly whenever user clicks in either of 153 * the layers. 154 * 155 * @private 156 * 157 * @param {Event} e 158 */ 159 onLayerClick: function(e) { 160 this.updateMap(); 161 }, 162 163 164 /** Cycles through the loaded data and base layer input arrays and makes 165 * the necessary calls to the Map object such that that the map's 166 * visual state corresponds to what the user has selected in the control 167 * 168 * @private 169 */ 170 updateMap: function() { 171 172 // set the newly selected base layer 173 for(var i=0; i < this.baseLayerInputs.length; i++) { 174 var input = this.baseLayerInputs[i]; 175 if (input.checked) { 176 this.map.setBaseLayer(input.layer, true); 177 } 178 } 179 180 // set the correct visibilities for the overlays 181 for(var i=0; i < this.dataLayerInputs.length; i++) { 182 var input = this.dataLayerInputs[i]; 183 input.layer.setVisibility(input.checked, true); 184 } 185 186 }, 187 188 /** Set up the labels and divs for the control 189 * 190 * @param {Event} e 191 */ 192 maximizeControl: function(e) { 193 194 //HACK HACK HACK - find a way to auto-size this layerswitcher 195 this.div.style.width = "20em"; 196 this.div.style.height = ""; 197 198 this.showControls(false); 199 200 if (e != null) { 201 Event.stop(e); 202 } 203 }, 204 205 /** Hide all the contents of the control, shrink the size, 206 * add the maximize icon 207 * 208 * @param {Event} e 209 */ 210 minimizeControl: function(e) { 211 212 this.div.style.width = "0px"; 213 this.div.style.height = "0px"; 214 215 // this.div.style.backgroundColor = "transparent"; 216 217 this.showControls(true); 218 219 if (e != null) { 220 Event.stop(e); 221 } 222 }, 223 224 /** Hide/Show all LayerSwitcher controls depending on whether we are 225 * minimized or not 226 * 227 * @private 228 * 229 * @param {Boolean} minimize 230 */ 231 showControls: function(minimize) { 232 233 this.maximizeDiv.style.display = minimize ? "" : "none"; 234 this.minimizeDiv.style.display = minimize ? "none" : ""; 235 236 this.layersDiv.style.display = minimize ? "none" : ""; 237 }, 238 239 /** Set up the labels and divs for the control 240 * 241 */ 242 loadContents: function() { 243 244 //configure main div 55 245 this.div.style.position = "absolute"; 56 246 this.div.style.top = "10px"; … … 58 248 this.div.style.left = ""; 59 249 this.div.style.fontFamily = "sans-serif"; 60 this.div.style.color = "white";61 250 this.div.style.fontWeight = "bold"; 62 251 this.div.style.marginTop = "3px"; 63 252 this.div.style.marginLeft = "3px"; 64 253 this.div.style.marginBottom = "3px"; 65 this.div.style.fontSize="smaller"; 66 this.div.style.width = "10em"; 67 68 this.map.events.register("addlayer", this, this.redraw); 69 this.map.events.register("removelayer", this, this.redraw); 70 this.map.events.register("changelayer", this, this.redraw); 71 return this.redraw(); 72 }, 73 74 /** 75 * @returns A reference to the DIV DOMElement containing the switcher tabs 76 * @type DOMElement 77 */ 78 redraw: function() { 79 80 //clear out previous incarnation of LayerSwitcher tabs 81 this.div.innerHTML = ""; 82 var visible = false; 83 for( var i = 0; i < this.map.layers.length; i++) { 84 if (visible && this.mode == "radio") { 85 this.map.layers[i].setVisibility(false); 86 } else { 87 visible = this.map.layers[i].getVisibility(); 88 } 89 this.addTab(this.map.layers[i]); 90 } 91 92 return this.div; 254 this.div.style.fontSize = "smaller"; 255 this.div.style.color = "white"; 256 this.div.style.backgroundColor = "transparent"; 257 258 Event.observe(this.div, "mouseup", 259 this.mouseUp.bindAsEventListener(this)); 260 Event.observe(this.div, "mousedown", 261 this.mouseDown.bindAsEventListener(this)); 262 Event.observe(this.div, "dblclick", this.ignoreEvent); 263 264 265 // layers list div 266 this.layersDiv = document.createElement("div"); 267 this.layersDiv.id = "layersDiv"; 268 this.layersDiv.style.paddingTop = "5px"; 269 this.layersDiv.style.paddingLeft = "10px"; 270 this.layersDiv.style.paddingBottom = "5px"; 271 this.layersDiv.style.paddingRight = "75px"; 272 this.layersDiv.style.backgroundColor = this.activeColor; 273 274 // had to set width/height to get transparency in IE to work. 275 // thanks -- http://jszen.blogspot.com/2005/04/ie6-opacity-filter-caveat.html 276 // 277 this.layersDiv.style.width = "100%"; 278 this.layersDiv.style.height = "100%"; 279 280 281 var baseLbl = document.createElement("div"); 282 baseLbl.innerHTML = "<u>Base Layer</u>"; 283 baseLbl.style.marginTop = "3px"; 284 baseLbl.style.marginLeft = "3px"; 285 baseLbl.style.marginBottom = "3px"; 286 this.layersDiv.appendChild(baseLbl); 287 288 this.baseLayersDiv = document.createElement("div"); 289 this.baseLayersDiv.style.paddingLeft = "10px"; 290 Event.observe(this.baseLayersDiv, "click", 291 this.onLayerClick.bindAsEventListener(this)); 292 this.layersDiv.appendChild(this.baseLayersDiv); 293 294 295 var dataLbl = document.createElement("div"); 296 dataLbl.innerHTML = "<u>Overlays</u>"; 297 dataLbl.style.marginTop = "3px"; 298 dataLbl.style.marginLeft = "3px"; 299 dataLbl.style.marginBottom = "3px"; 300 this.layersDiv.appendChild(dataLbl); 301 302 this.dataLayersDiv = document.createElement("div"); 303 this.dataLayersDiv.style.paddingLeft = "10px"; 304 Event.observe(this.dataLayersDiv, "click", 305 this.onLayerClick.bindAsEventListener(this)); 306 this.layersDiv.appendChild(this.dataLayersDiv); 307 308 this.div.appendChild(this.layersDiv); 309 310 Rico.Corner.round(this.div, {corners: "tl bl", 311 bgColor: "transparent", 312 color: this.activeColor, 313 blend: false}); 314 315 Rico.Corner.changeOpacity(this.layersDiv, 0.75); 316 317 var imgLocation = OpenLayers.Util.getImagesLocation(); 318 var sz = new OpenLayers.Size(18,18); 319 320 // maximize button div 321 var img = imgLocation + 'layer-switcher-maximize.png'; 322 this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv( 323 "OpenLayers_Control_ResizeDiv", 324 null, 325 sz, 326 img, 327 "absolute"); 328 this.maximizeDiv.style.top = "5px"; 329 this.maximizeDiv.style.right = "0px"; 330 this.maximizeDiv.style.left = ""; 331 this.maximizeDiv.style.display = "none"; 332 Event.observe(this.maximizeDiv, 333 "click", 334 this.maximizeControl.bindAsEventListener(this)); 335 336 this.div.appendChild(this.maximizeDiv); 337 338 // minimize button div 339 var img = imgLocation + 'layer-switcher-minimize.png'; 340 var sz = new OpenLayers.Size(18,18); 341 this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv( 342 "OpenLayers_Control_ResizeDiv", 343 null, 344 sz, 345 img, 346 "absolute"); 347 this.minimizeDiv.style.top = "5px"; 348 this.minimizeDiv.style.right = "0px"; 349 this.minimizeDiv.style.left = ""; 350 this.minimizeDiv.style.display = "none"; 351 Event.observe(this.minimizeDiv, 352 "click", 353 this.minimizeControl.bindAsEventListener(this)); 354 355 this.div.appendChild(this.minimizeDiv); 93 356 }, 94 357 95 358 /** 96 * @param {event} evt 97 */ 98 singleClick: function(evt) { 99 var div = Event.element(evt); 100 101 // See comment about OL #57 fix below. 102 // If the click occurred on the corner spans we need 103 // to make sure we act on the actual label tab instead. 104 div = div.labelElement || div; 105 106 var layer = div.layer; 107 if (this.mode == "radio") { 108 for(var i=0; i < this.backdrops.length; i++) { 109 this.setTabActivation(this.backdrops[i], false); 110 this.backdrops[i].layer.setVisibility(false); 111 } 112 this.setTabActivation(div, true); 113 layer.setVisibility(true); 114 } else { 115 var visible = layer.getVisibility(); 116 117 this.setTabActivation(div, !visible); 118 layer.setVisibility(!visible); 119 } 120 Event.stop(evt); 121 }, 122 123 /** 124 * @private 125 * 126 * @param {event} evt 127 */ 359 * @private 360 * 361 * @param {Event} evt 362 */ 128 363 ignoreEvent: function(evt) { 129 364 Event.stop(evt); 130 return false; 131 }, 132 133 /** 134 * @private 135 * 136 * @param {OpenLayers.Layer} layer 137 */ 138 addTab: function(layer) { 139 140 // Outer DIV - for Rico Corners 141 // 142 var backdropLabelOuter = document.createElement('div'); 143 backdropLabelOuter.id = "LayerSwitcher_" + layer.name + "_Tab"; 144 backdropLabelOuter.style.marginTop = "4px"; 145 backdropLabelOuter.style.marginBottom = "4px"; 146 147 this._setEventHandlers(backdropLabelOuter); 148 149 // Inner Label - for Rico Corners 150 // 151 var backdropLabel = document.createElement('p'); 152 backdropLabel.innerHTML = layer.name; 153 backdropLabel.style.marginTop = "0px"; 154 backdropLabel.style.marginBottom = "0px"; 155 backdropLabel.style.paddingLeft = "10px"; 156 backdropLabel.style.paddingRight = "10px"; 157 158 // add reference to layer onto the div for use in event handlers 159 backdropLabel.layer = layer; 160 161 // set event handlers 162 this._setEventHandlers(backdropLabel); 163 164 // add label to div 165 backdropLabelOuter.appendChild(backdropLabel); 166 167 this.backdrops.append(backdropLabel); 168 169 // add div to main LayerSwitcher Div 170 this.div.appendChild(backdropLabelOuter); 171 172 Rico.Corner.round(backdropLabelOuter, {corners: "tl bl", 173 bgColor: "transparent", 174 color: "white", 175 blend: false}); 176 177 // extend the event handlers to operate on the 178 // rounded corners as well. (Fixes OL #57.) 179 var spanElements=backdropLabel.parentNode.getElementsByTagName("span"); 180 181 for (var currIdx = 0; currIdx < spanElements.length; currIdx++) { 182 this._setEventHandlers(spanElements[currIdx], backdropLabel); 183 } 184 185 this.setTabActivation(backdropLabel, layer.getVisibility()); 186 }, 187 188 /* 189 @private 190 191 @param {DOMElement} div 192 @param {Boolean} activate 193 */ 194 _setEventHandlers : function(element, labelDiv) { 195 196 // We only want to respond to a mousedown event. 197 element.onclick = this.singleClick.bindAsEventListener(this); 198 element.ondblclick = this.singleClick.bindAsEventListener(this); 199 element.onmouseup = this.ignoreEvent.bindAsEventListener(this); 200 element.onmousedown = this.ignoreEvent.bindAsEventListener(this); 201 202 // If we are operating on a corner span we need to store a 203 // reference to the actual tab. (See comment about OL #57 fix above.) 204 if (labelDiv) { 205 element.labelElement = labelDiv; 206 } 207 }, 208 209 /** 210 * @private 211 * 212 * @param {DOMElement} div 213 * @param {Boolean} activate 214 */ 215 setTabActivation:function(div, activate) { 216 var color = (activate) ? this.activeColor : this.nonActiveColor; 217 Rico.Corner.changeColor(div, color); 218 }, 219 220 365 }, 366 367 /** Register a local 'mouseDown' flag so that we'll know whether or not 368 * to ignore a mouseUp event 369 * 370 * @private 371 * 372 * @param {Event} evt 373 */ 374 mouseDown: function(evt) { 375 this.mouseDown = true; 376 this.ignoreEvent(evt); 377 }, 378 379 /** If the 'mouseDown' flag has been set, that means that the drag was 380 * started from within the LayerSwitcher control, and thus we can 381 * ignore the mouseup. Otherwise, let the Event continue. 382 * 383 * @private 384 * 385 * @param {Event} evt 386 */ 387 mouseUp: function(evt) { 388 if (this.mouseDown) { 389 this.mouseDown = false; 390 this.ignoreEvent(evt); 391 } 392 }, 221 393 222 394 /** @final @type String */ 223 395 CLASS_NAME: "OpenLayers.Control.LayerSwitcher" 224 396 }); 225 trunk/openlayers/lib/OpenLayers/Control/MouseToolbar.js
r961 r1096 86 86 defaultDblClick: function (evt) { 87 87 this.switchModeTo("pan"); 88 this.performedDrag = false; 88 89 var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); 89 90 this.map.setCenter(newCenter, this.map.zoom + 2); … … 96 97 if (!Event.isLeftClick(evt)) return; 97 98 this.mouseDragStart = evt.xy.clone(); 99 this.performedDrag = false; 98 100 if (evt.shiftKey && this.mode !="zoombox") { 99 101 this.switchModeTo("zoombox"); … … 218 220 this.mouseDragStart = evt.xy.clone(); 219 221 } 222 this.performedDrag = true; 220 223 } 221 224 }, … … 245 248 break; 246 249 case "pan": 247 this.map.setCenter(this.map.center); 248 250 if (this.performedDrag) { 251 this.map.setCenter(this.map.center); 252 } 249 253 } 250 254 document.onselectstart = null; trunk/openlayers/lib/OpenLayers/Icon.js
r877 r1096 96 96 } 97 97 98 if ((this.px != null) && (this.imageDiv != null)) { 99 if (this.calculateOffset) { 100 this.offset = this.calculateOffset(this.size); 98 if (this.imageDiv != null) { 99 if (this.px == null) { 100 this.display(false); 101 } else { 102 if (this.calculateOffset) { 103 this.offset = this.calculateOffset(this.size); 104 } 105 var offsetPx = this.px.offset(this.offset); 106 OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, offsetPx); 107 this.display(true); 101 108 } 102 var offsetPx = this.px.offset(this.offset);103 OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, offsetPx);104 109 } 110 }, 111 112 /** Hide or show the icon 113 * 114 * @param {Boolean} display 115 */ 116 display: function(display) { 117 this.imageDiv.style.display = (display) ? "" : "none"; 105 118 }, 106 119 trunk/openlayers/lib/OpenLayers/Layer.js
r1050 r1096 23 23 map: null, 24 24 25 25 /** Whether or not the layer is a base layer. This should be set 26 * individually by all subclasses. 27 * Default is false 28 * 29 * @type Boolean 30 */ 31 isBaseLayer: false, 32 26 33 // OPTIONS 27 34 … … 136 143 //this function can be implemented by subclasses. 137 144 }, 145 146 /** 147 */ 148 reproject:function() { 149 //this function can be implemented by subclasses. 150 }, 138 151 139 152 /** Set the map property for the layer. This is done through an accessor … … 148 161 149 162 /** 150 * @returns Whether or not the layer is a base layer. This should be151 * determined individually by all subclasses. Default is false152 * @type Boolean153 */154 isBaseLayer: function() {155 //this function should be implemented by all subclasses.156 return false;157 },158 159 /**160 163 * @returns Whether or not the layer is visible 161 164 * @type Boolean … … 166 169 167 170 /** 168 * @param {bool} visible 169 */ 170 setVisibility: function(visible) { 171 * @param {Boolean} visible 172 * @param {Boolean} noEvent 173 */ 174 setVisibility: function(visible, noEvent) { 171 175 if (visible != this.getVisibility()) { 172 176 this.div.style.display = (visible) ? "block" : "none"; 173 if (this.map != null) { 174 if (visible) { 175 var extent = this.map.getExtent(); 176 if (extent != null) { 177 this.moveTo(this.map.getExtent()); 178 } 177 if ((visible) && (this.map != null)) { 178 var extent = this.map.getExtent(); 179 if (extent != null) { 180 this.moveTo(this.map.getExtent()); 179 181 } 182 } 183 if ((this.map != null) && 184 ((noEvent == null) || (noEvent == false))) { 180 185 this.map.events.triggerEvent("changelayer"); 181 186 } trunk/openlayers/lib/OpenLayers/Layer/GeoRSS.js
r804 r1096 11 11 Object.extend( new OpenLayers.Layer.Markers(), { 12 12 13 /** GeoRSS layer is never a base layer. 14 * @type Boolean 15 */ 16 isBaseLayer: false, 17 13 18 /** store url of text file 14 19 * @type str */ … … 42 47 OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments); 43 48 }, 44 45 /** WFS layer is never a base class. 46 * @type Boolean 47 */ 48 isBaseLayer: function() { 49 return false; 50 }, 51 52 49 53 50 /** 54 51 * @param {?} ajaxRequest trunk/openlayers/lib/OpenLayers/Layer/Google.js
r1051 r1096 38 38 OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), { 39 39 40 41 /** Google layer is always base layer 42 * 43 * @type Boolean 44 */ 45 isBaseLayer: true, 46 40 47 /** @type Boolean */ 41 48 isFixed: true, … … 43 50 /** @type GMap2 gmap stores the Google Map element */ 44 51 gmap:null, 52 53 /** @type GMapType */ 54 type: null, 45 55 46 56 /** @type Boolean */ 47 57 dragging:false, 58 59 /** @type Boolean */ 60 dontListen:false, 48 61 49 62 // OPTIONS … … 83 96 OpenLayers.Layer.prototype.setMap.apply(this, arguments); 84 97 85 // once our layer has been added to the map, we can create the vemap 86 this.map.events.register("addlayer", this, this.loadGMap); 87 }, 88 89 /** Google layer is a base class if the GMap loaded correctly. 90 * @type Boolean 91 */ 92 isBaseLayer: function() { 93 return (this.gmap != null); 94 }, 95 96 /** Assuming we are not dragging (in which case GMaps moving itself) 97 * we need to move the gmap to the new center/zoom 98 // once our layer has been added to the map, we can load it 99 this.loadGMap(); 100 }, 101 102 /** Assuming we are not dragging (in which case GMaps is moving itself, 103 * and the dragging flag is set) we need to move the gmap to the 104 * new center/zoom 98 105 * 99 106 * @param {OpenLayers.Bounds} bounds … … 118 125 (newZoom != currentZoom) ) { 119 126 127 this.dontListen = true; 120 128 this.gmap.setCenter(this.getGLatLngFromOLLonLat(newCenter), 121 129 this.getGZoomFromOLZoom(newZoom)); 122 130 131 if (this.type != null) { 132 this.gmap.setMapType(this.type); 133 this.type = null; 134 } 135 136 this.dontListen = false; 123 137 } 124 138 } … … 137 151 try { 138 152 // create GMap, hide nav controls 139 this.gmap = new GMap2(this.div );140 153 this.gmap = new GMap2(this.div ); 154 141 155 // this causes the GMap to set itself to Map's center/zoom 142 156 this.moveTo(); 143 157 158 144 159 // catch pans and zooms from GMap 145 160 GEvent.addListener(this.gmap, … … 241 256 */ 242 257 catchPanZoom: function(e) { 243 244 var gCenter = this.gmap.getCenter(); 245 var gZoom = this.gmap.getZoom(); 246 247 var olCenter = this.getOLLonLatFromGLatLng(gCenter); 248 var olZoom = this.getOLZoomFromGZoom(gZoom); 249 250 this.map.setCenter(olCenter, olZoom); 258 259 if (!this.dontListen) { 260 261 var gCenter = this.gmap.getCenter(); 262 var gZoom = this.gmap.getZoom(); 263 264 var olCenter = this.getOLLonLatFromGLatLng(gCenter); 265 var olZoom = this.getOLZoomFromGZoom(gZoom); 266 267 this.map.setCenter(olCenter, olZoom, this.dragging); 268 } 251 269 }, 252 270 … … 339 357 var zoom = null; 340 358 if (gZoom != null) { 341 zoom = gZoom - 1;359 zoom = gZoom; 342 360 } 343 361 return zoom; … … 354 372 var zoom = null; 355 373 if (olZoom != null) { 356 zoom = olZoom + 1;374 zoom = olZoom; 357 375 } 358
