comparison src/djol/LayerRadioButton.js @ 8:f0035923ff3e

добавлена библиотека для работы с openlayers 3+
author cin
date Mon, 21 Aug 2017 17:47:00 +0300
parents
children
comparison
equal deleted inserted replaced
7:9c0943c68a90 8:f0035923ff3e
1 define([
2 "dojo/_base/declare",
3 "dijit/_WidgetBase",
4 "dijit/_TemplatedMixin",
5 "dijit/_WidgetsInTemplateMixin",
6 "dojo/text!./resources/LayerRadioButtonTemplate.html",
7 "dijit/form/RadioButton" ], function(declare, _WidgetBase, _TemplatedMixin,
8 _WidgetsInTemplateMixin, templateString) {
9 return declare([ _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin ], {
10 templateString : templateString,
11
12 labelNode : null,
13 radioButton : null,
14
15 label : "",
16 _setLabelAttr : {
17 node : "labelNode",
18 type : "innerHTML"
19 },
20
21 name : "layers",
22
23 _layer : null,
24
25 constructor : function(options) {
26 options = options || {};
27
28 if (!options.layer)
29 throw new Error("The layer is required");
30
31 this._layer = options.layer;
32 this.label = options.layer.get("label") || "unnamed";
33 },
34
35 postCreate : function() {
36 var me = this;
37 me.inherited(arguments);
38
39 me.radioButton.set('name', me.name);
40 me.radioButton.set('value', me._layer.getVisible());
41 this.radioButton.on("change", function(value) {
42 me._changed(value);
43 });
44 },
45
46 _changed : function(visible) {
47 this._layer.setVisible(visible);
48 }
49 });
50 });