Ai
1 Star 0 Fork 0

opengis-leaflet/leaflet-fractal

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
PaletteControl.js 1.80 KB
一键复制 编辑 原始数据 按行查看 历史
Alexander Parshin 提交于 2013-04-13 13:51 +08:00 . Add palette control
var PaletteControl = L.Control.extend({
options: {
initPalette: 'hsv'
},
initialize: function(fractalLayers, options) {
L.setOptions(this, options);
this._fractalLayers = fractalLayers;
},
onAdd: function (map) {
// create the control container with a particular class name
var container = L.DomUtil.create('div', 'leaflet-control-layers leaflet-control-layers-expanded');
var _this = this;
var title = document.createElement('span');
title.innerHTML = 'Palette ';
var buttonsContainer = L.DomUtil.create('div', 'fractal-palette-buttons');
this._buttons = [];
paletteController.forEach(function(paletteName) {
var paletteButton = L.DomUtil.create('button', 'fractal-palette-button', buttonsContainer);
paletteButton.innerHTML = paletteName;
paletteButton.paletteName = paletteName;
_this._buttons.push(paletteButton);
L.DomEvent.on(paletteButton, 'click', function() {
_this._update(this.paletteName);
});
})
this._update(this.options.initPalette);
container.appendChild(title);
container.appendChild(buttonsContainer);
return container;
},
_update: function(activePaletteName) {
this._buttons.forEach(function(button) {
if (button.paletteName !== activePaletteName) {
L.DomUtil.removeClass(button, 'fractal-palette-button-active');
} else {
L.DomUtil.addClass(button, 'fractal-palette-button-active');
}
})
for (var l in this._fractalLayers) {
this._fractalLayers[l].setPalette(activePaletteName);
}
}
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/opengis-leaflet/leaflet-fractal.git
git@gitee.com:opengis-leaflet/leaflet-fractal.git
opengis-leaflet
leaflet-fractal
leaflet-fractal
master

搜索帮助