OpenLayers OpenLayers

Changeset 1096

Show
Ignore:
Timestamp:
08/08/06 14:20:24 (2 years ago)
Author:
euzuro
Message:

new layerswitcher, improved google layer, boxes layer, grid fix

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/examples/google.html

    r915 r1096  
    2323        function init(){ 
    2424            map = new OpenLayers.Map( $('map') ); 
    25             gmap = new OpenLayers.Layer.Google( "Google" ); 
     25            gmap = new OpenLayers.Layer.Google( "Google" , {type: G_HYBRID_MAP }); 
    2626            map.addLayer(gmap); 
    2727 
     
    3131            map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); 
    3232            map.addControl( new OpenLayers.Control.LayerSwitcher() ); 
     33 
    3334        } 
    3435         
     
    4243            markers.removeMarker(marker); 
    4344        } 
    44          
     45                 
    4546    // --> 
    4647 
     
    5051    <h1>OpenLayers With Google Layer Example</h1> 
    5152    <div id="map"></div> 
    52     <div style="background-color:green" onclick="add()"> click to add the marker to the map</div> 
    5353    <div style="background-color:red" onclick="remove()"> click to remove the marker from the map</div> 
    5454  </body> 
  • trunk/openlayers/lib/OpenLayers.js

    r965 r1096  
    5959        "OpenLayers/Icon.js", 
    6060        "OpenLayers/Marker.js", 
     61        "OpenLayers/Marker/Box.js", 
    6162        "OpenLayers/Popup.js", 
    6263        "OpenLayers/Tile.js", 
     
    7879        "OpenLayers/Layer/WMS/Untiled.js", 
    7980        "OpenLayers/Layer/GeoRSS.js", 
     81        "OpenLayers/Layer/Boxes.js", 
    8082        "OpenLayers/Popup/Anchored.js", 
    8183        "OpenLayers/Popup/AnchoredBubble.js", 
     
    8890        "OpenLayers/Control/Permalink.js", 
    8991        "OpenLayers/Control/Scale.js", 
    90         "OpenLayers/Control/LayerSwitcher.js" 
     92        "OpenLayers/Control/LayerSwitcher.js", 
     93        "OpenLayers/Control/LayerTabs.js" 
    9194    ); // etc. 
    9295 
  • trunk/openlayers/lib/OpenLayers/Control/LayerSwitcher.js

    r1050 r1096  
    22 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full 
    33 * text of the license. */ 
     4 
    45// @require: OpenLayers/Control.js 
     6 
    57/**  
    68* @class 
    79*/ 
    810OpenLayers.Control.LayerSwitcher = Class.create(); 
    9  
    10 /** color used in the UI to show a layer is active/displayed 
    11 * 
    12 * @final 
    13 * @type String  
    14 */ 
    15 OpenLayers.Control.LayerSwitcher.ACTIVE_COLOR = "darkblue"; 
    16  
    17 /** color used in the UI to show a layer is deactivated/hidden 
    18 * 
    19 * @final 
    20 * @type String  
    21 */ 
    22 OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR = "lightblue"; 
    23  
    24  
    2511OpenLayers.Control.LayerSwitcher.prototype =  
    2612  Object.extend( new OpenLayers.Control(), { 
    2713 
    2814    /** @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     
    3742    /** 
    3843    * @constructor 
    3944    */ 
    4045    initialize: function(options) { 
    41         this.activeColor = OpenLayers.Control.LayerSwitcher.ACTIVE_COLOR; 
    42         this.nonActiveColor = OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR; 
    43         this.backdrops = []; 
    4446        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); 
    4559    }, 
    4660 
     
    5064    */   
    5165    draw: function() { 
    52         // initialize our internal div 
    5366        OpenLayers.Control.prototype.draw.apply(this); 
    5467 
     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 
    55245        this.div.style.position = "absolute"; 
    56246        this.div.style.top = "10px"; 
     
    58248        this.div.style.left = ""; 
    59249        this.div.style.fontFamily = "sans-serif"; 
    60         this.div.style.color = "white"; 
    61250        this.div.style.fontWeight = "bold"; 
    62251        this.div.style.marginTop = "3px"; 
    63252        this.div.style.marginLeft = "3px"; 
    64253        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); 
    93356    }, 
    94357     
    95358    /**  
    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     */ 
    128363    ignoreEvent: function(evt) { 
    129364        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    }, 
    221393 
    222394    /** @final @type String */ 
    223395    CLASS_NAME: "OpenLayers.Control.LayerSwitcher" 
    224396}); 
    225  
  • trunk/openlayers/lib/OpenLayers/Control/MouseToolbar.js

    r961 r1096  
    8686    defaultDblClick: function (evt) { 
    8787        this.switchModeTo("pan"); 
     88        this.performedDrag = false; 
    8889        var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );  
    8990        this.map.setCenter(newCenter, this.map.zoom + 2); 
     
    9697        if (!Event.isLeftClick(evt)) return; 
    9798        this.mouseDragStart = evt.xy.clone(); 
     99        this.performedDrag = false; 
    98100        if (evt.shiftKey && this.mode !="zoombox") { 
    99101            this.switchModeTo("zoombox"); 
     
    218220                    this.mouseDragStart = evt.xy.clone(); 
    219221            } 
     222            this.performedDrag = true; 
    220223        } 
    221224    }, 
     
    245248                break; 
    246249            case "pan": 
    247                 this.map.setCenter(this.map.center); 
    248              
     250                if (this.performedDrag) { 
     251                    this.map.setCenter(this.map.center); 
     252                }         
    249253        } 
    250254        document.onselectstart = null; 
  • trunk/openlayers/lib/OpenLayers/Icon.js

    r877 r1096  
    9696        } 
    9797 
    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); 
    101108            } 
    102             var offsetPx = this.px.offset(this.offset); 
    103             OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, offsetPx); 
    104109        } 
     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";  
    105118    }, 
    106119     
  • trunk/openlayers/lib/OpenLayers/Layer.js

    r1050 r1096  
    2323    map: null, 
    2424     
    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  
    2633  // OPTIONS 
    2734 
     
    136143        //this function can be implemented by subclasses. 
    137144    }, 
     145 
     146    /** 
     147     */ 
     148    reproject:function() { 
     149        //this function can be implemented by subclasses. 
     150    }, 
    138151     
    139152    /** Set the map property for the layer. This is done through an accessor 
     
    148161   
    149162    /** 
    150      * @returns Whether or not the layer is a base layer. This should be  
    151      *          determined individually by all subclasses. Default is false 
    152      * @type Boolean 
    153      */ 
    154     isBaseLayer: function() { 
    155         //this function should be implemented by all subclasses. 
    156         return false; 
    157     }, 
    158      
    159     /** 
    160163    * @returns Whether or not the layer is visible 
    161164    * @type Boolean 
     
    166169 
    167170    /**  
    168     * @param {bool} visible 
    169     */ 
    170     setVisibility: function(visible) { 
     171     * @param {Boolean} visible 
     172     * @param {Boolean} noEvent 
     173     */ 
     174    setVisibility: function(visible, noEvent) { 
    171175        if (visible != this.getVisibility()) { 
    172176            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()); 
    179181                } 
     182            } 
     183            if ((this.map != null) &&  
     184                ((noEvent == null) || (noEvent == false))) { 
    180185                this.map.events.triggerEvent("changelayer"); 
    181186            } 
  • trunk/openlayers/lib/OpenLayers/Layer/GeoRSS.js

    r804 r1096  
    1111  Object.extend( new OpenLayers.Layer.Markers(), { 
    1212 
     13    /** GeoRSS layer is never a base layer.  
     14     * @type Boolean 
     15     */ 
     16    isBaseLayer: false, 
     17     
    1318    /** store url of text file 
    1419    * @type str */ 
     
    4247        OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments); 
    4348    }, 
    44      
    45     /** WFS layer is never a base class.  
    46      * @type Boolean 
    47      */ 
    48     isBaseLayer: function() { 
    49         return false; 
    50     }, 
    51      
    52      
     49         
    5350    /** 
    5451     * @param {?} ajaxRequest 
  • trunk/openlayers/lib/OpenLayers/Layer/Google.js

    r1051 r1096  
    3838OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), { 
    3939 
     40     
     41    /** Google layer is always base layer 
     42     *  
     43     * @type Boolean 
     44     */ 
     45    isBaseLayer: true, 
     46     
    4047    /** @type Boolean */ 
    4148    isFixed: true, 
     
    4350    /** @type GMap2 gmap stores the Google Map element */ 
    4451    gmap:null, 
     52 
     53    /** @type GMapType */ 
     54    type: null, 
    4555    
    4656    /** @type Boolean */ 
    4757    dragging:false, 
     58 
     59    /** @type Boolean */ 
     60    dontListen:false, 
    4861     
    4962  // OPTIONS 
     
    8396        OpenLayers.Layer.prototype.setMap.apply(this, arguments); 
    8497 
    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 
    98105     *  
    99106     * @param {OpenLayers.Bounds} bounds 
     
    118125                     (newZoom != currentZoom) ) { 
    119126     
     127                    this.dontListen = true; 
    120128                    this.gmap.setCenter(this.getGLatLngFromOLLonLat(newCenter),  
    121129                                        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; 
    123137                } 
    124138            } 
     
    137151        try { 
    138152            // create GMap, hide nav controls 
    139             this.gmap = new GMap2(this.div); 
    140          
     153            this.gmap = new GMap2(this.div ); 
     154             
    141155            // this causes the GMap to set itself to Map's center/zoom 
    142156            this.moveTo(); 
    143      
     157 
     158 
    144159            // catch pans and zooms from GMap 
    145160            GEvent.addListener(this.gmap,  
     
    241256     */ 
    242257    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        } 
    251269    }, 
    252270     
     
    339357        var zoom = null; 
    340358        if (gZoom != null) { 
    341             zoom = gZoom - 1
     359            zoom = gZoom
    342360        } 
    343361        return zoom; 
     
    354372        var zoom = null;  
    355373        if (olZoom != null) { 
    356             zoom = olZoom + 1
     374            zoom = olZoom
    357375        } 
    358