/** * ol3-ext - A set of cool extensions for OpenLayers 3 (ol3). * @abstract ol3,openlayers,popup,menu,symbol,renderer,filter,canvas,interaction,split,statistic,charts,pie,LayerSwitcher,toolbar,animation * @version v1.0.1 * @author Jean-Marc Viglino (https://github.com/Viglino) * @link https://github.com/Viglino/ol3-ext#, * @license CECILL-B */ /* Copyright (c) 2015 Jean-Marc VIGLINO, released under the CeCILL-B license (French BSD license) (http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt). */ /** * @classdesc OpenLayers 3 Layer Switcher Control. * @require jQuery * * @constructor * @extends {ol.control.Control} * @param {Object=} Control options. * - show_progress {boolean} show a progress bar on tile layers, default false * - mouseover {boolean} show the panel on mouseover, default false * - reordering {boolean} allow layer reordering, default true * - trash {boolean} add a trash button to delete the layer, default false * - oninfo {function} callback on click on info button, if none no info button is shown * - extent {boolean} add an extent button to zoom to the extent of the layer * - onextent {function} callback when click on extent, default fits view to extent * * Layers attributes that control the switcher * - allwaysOnTop {boolean} true to force layer stay on top of the others while reordering, default false * - displayInLayerSwitcher {boolean} display in switcher, default true * - noSwitcherDelete {boolean} to prevent layer deletion (w. trash option), default false */ ol.control.LayerSwitcher = function(opt_options) { var options = opt_options || {}; var self = this; this.dcount = 0; this.show_progress = options.show_progress; this.oninfo = (typeof (options.oninfo) == "function" ? options.oninfo: null); this.onextent = (typeof (options.onextent) == "function" ? options.onextent: null); this.hasextent = options.extent || options.onextent; this.hastrash = options.trash; this.reordering = (options.reordering!==false); var element; if (options.target) { element = $("
").addClass(options.switcherClass || "ol-layerswitcher"); } else { element = $("
").addClass((options.switcherClass || 'ol-layerswitcher') +' ol-unselectable ol-control ol-collapsed'); this.button = $("