add a 'changelayer' event that fires when a layer's visibility changes. listen for this in the layerswitcher
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1050 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -67,6 +67,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
|||||||
|
|
||||||
this.map.events.register("addlayer", this, this.redraw);
|
this.map.events.register("addlayer", this, this.redraw);
|
||||||
this.map.events.register("removelayer", this, this.redraw);
|
this.map.events.register("removelayer", this, this.redraw);
|
||||||
|
this.map.events.register("changelayer", this, this.redraw);
|
||||||
return this.redraw();
|
return this.redraw();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
+10
-5
@@ -168,11 +168,16 @@ OpenLayers.Layer.prototype = {
|
|||||||
* @param {bool} visible
|
* @param {bool} visible
|
||||||
*/
|
*/
|
||||||
setVisibility: function(visible) {
|
setVisibility: function(visible) {
|
||||||
this.div.style.display = (visible) ? "block" : "none";
|
if (visible != this.getVisibility()) {
|
||||||
if ((visible) && (this.map != null)) {
|
this.div.style.display = (visible) ? "block" : "none";
|
||||||
var extent = this.map.getExtent();
|
if (this.map != null) {
|
||||||
if (extent != null) {
|
if (visible) {
|
||||||
this.moveTo(this.map.getExtent());
|
var extent = this.map.getExtent();
|
||||||
|
if (extent != null) {
|
||||||
|
this.moveTo(this.map.getExtent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.map.events.triggerEvent("changelayer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ OpenLayers.Map.prototype = {
|
|||||||
*
|
*
|
||||||
* @type Array */
|
* @type Array */
|
||||||
EVENT_TYPES: [
|
EVENT_TYPES: [
|
||||||
"addlayer", "removelayer", "movestart", "move", "moveend",
|
"addlayer", "removelayer", "changelayer", "movestart", "move",
|
||||||
"zoomend", "layerchanged", "popupopen", "popupclose",
|
"moveend", "zoomend", "layerchanged", "popupopen", "popupclose",
|
||||||
"addmarker", "removemarker", "clearmarkers", "mouseover",
|
"addmarker", "removemarker", "clearmarkers", "mouseover",
|
||||||
"mouseout", "mousemove", "dragstart", "drag", "dragend",
|
"mouseout", "mousemove", "dragstart", "drag", "dragend",
|
||||||
"changebaselayer"],
|
"changebaselayer"],
|
||||||
|
|||||||
Reference in New Issue
Block a user