IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Bibliothèques & Frameworks Discussion :

Afficher les CHECKBOX du layer


Sujet :

Bibliothèques & Frameworks

  1. #1
    Membre à l'essai
    Homme Profil pro
    Responsable de service informatique
    Inscrit en
    Décembre 2015
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Landes (Aquitaine)

    Informations professionnelles :
    Activité : Responsable de service informatique

    Informations forums :
    Inscription : Décembre 2015
    Messages : 44
    Points : 16
    Points
    16
    Par défaut Afficher les CHECKBOX du layer
    Bonjour,

    j'ai un soucis avec le L.control.groupedLayers sur ma carte : http://incident.cc-cln.fr/plu.html

    En effet les cases à cochés n'apparaissent pas, avez-vous une solution à me proposer??

    voici le css:

    Code css : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    .leaflet-control-layers-group-name {
        font-weight: bold;
        margin-bottom: .2em;
    	margin-left: 3px;
    	color: #00549B;
      }
      /*test*/
     
    /* PANEL LAYERS */
    .leaflet-control-layers .leaflet-control-layers-list {
    	display: block;
    }
    .leaflet-control-layers.expanded .leaflet-control-layers-list {
    	display: block;
    }
    .leaflet-top.leaflet-right .leaflet-control-layers:not(.compact) {
    	margin: 0;
    }
    .leaflet-control-layers {
    	width: 300px;
    	min-width: 300px;
    }
    .leaflet-control-layers.expanded {	
    	width: auto;
    	overflow-x: hidden;
    	overflow-y: auto;
    }
    .leaflet-control-layers.expanded .leaflet-control-layers-list {
    	display: block;
    }
    .leaflet-control-layers:not(.expanded) .leaflet-control-layers-title > span,
    .leaflet-control-layers:not(.expanded) .leaflet-control-layers-selector,
    .leaflet-control-layers:not(.expanded) .leaflet-control-layers-grouplabel {
        display: none;
    }
    .leaflet-control-layers-separator {
    	clear: both;
    }
     
    .leaflet-control-layers-item .leaflet-control-layers-title {
    	display: block;
    	white-space: nowrap;
    	float: none;
    	cursor: pointer;
    }
    .leaflet-control-layers-title .leaflet-control-layers-selector {
    	float: right;
    }
     
    .leaflet-control-layers-group {	
    	position: relative;
    	width: auto;
    	height: auto;
    	clear: both;
    	overflow: hidden;
    }
    .leaflet-control-layers-icon {
    	text-align: center;
    	float: left;
    }
    .leaflet-control-layers-group.collapsible:not(.expanded) {
        height: 20px;
    }
    .leaflet-control-layers-group.collapsible:not(.expanded) .leaflet-control-layers-grouplabel {
    	height: 20px;
    	overflow: hidden;
    }
    .leaflet-control-layers-group.collapsible:not(.expanded) .leaflet-control-layers-item {
        display: none;    
    }
    .leaflet-control-layers-group.collapsible .leaflet-control-layers-icon:first-child {
    	cursor: pointer;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    .leaflet-control-layers-item {
    	display: block;
    	height: auto;
    	clear: both;
    	white-space: nowrap;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    .leaflet-control-layers-overlays .leaflet-control-layers-item {	
    	white-space: pre-wrap;
    	white-space: -moz-pre-wrap;
    	white-space: -pre-wrap;
    	white-space: -o-pre-wrap;
    	word-wrap: break-word;
    	width: auto;
    	display: block;
    }
    .leaflet-control-layers-base .leaflet-control-layers-selector {
    	float: left;
    }
    .leaflet-control-layers-overlays .leaflet-control-layers-selector {
    	float: right;
    }
    .leaflet-control-layers.expanded .leaflet-control-layers-overlays input {
    	display: block;
    }
    .leaflet-control-layers-selector {
    	float: left;
    }
     
     
    /* theming style */
     
    .leaflet-control-layers {
    	padding: 4px;
    	background: rgba(255,255,255,0.5);
    	box-shadow: -2px 0 8px rgba(0,0,0,0.3);
    }
    .leaflet-control-layers.expanded {
    	padding: 4px;
    }
    .leaflet-control-layers-selector {
    	position: relative;
    	top: 1px;
    	margin-top: 2px;	
    }
    .leaflet-control-layers-separator {
    	height: 8px;
    	margin: 12px 4px 0 4px;	
    	border-top:1px solid rgba(0,0,0,0.3);
    }
    .leaflet-control-layers-item {
    	min-height: 20px;	
    }
    .leaflet-control-layers-margin {
        height: 25px;
    }
    .leaflet-control-layers-icon {
    	line-height: 20px;
    	display: inline-block;	
    	height: 20px;
    	width: 20px;	
    	background: #fff;
    }
    .leaflet-control-layers-group.collapsible .leaflet-control-layers-icon:first-child {
    	min-width: 20px;
    	font-size: 16px;
    	text-align: center;
    	background: none;
    }
    .leaflet-control-layers-group {	
    	padding: 2px 4px;
    	margin-bottom: 4px;	
    	border: 1px solid rgba(0,0,0,0.3);
    	background: rgba(255,255,255,0.6);
    	border-radius: 3px;
    }
    .leaflet-control-layers-overlays .leaflet-control-layers-item {
    	margin-bottom: 4px;
    	padding: 2px;	
    	background: #fff;
    	border: 1px solid rgba(0,0,0,0.3);
    	border-radius: 4px;
    }
    .leaflet-control-layers-overlays .leaflet-control-layers-item:hover {
    	border: 1px solid #888;
    	cursor: pointer;
    }

    et le js:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    /* global L */
     
    // A layer control which provides for layer groupings.
    // Author: Ishmael Smyrnow
    L.Control.GroupedLayers = L.Control.extend({
     
        options: {
          collapsed: true,
          position: 'topright',
          autoZIndex: true,
          exclusiveGroups: [],
          groupCheckboxes: false
        },
     
        initialize: function (baseLayers, groupedOverlays, options) {
          var i, j;
          L.Util.setOptions(this, options);
     
          this._layers = [];
          this._lastZIndex = 0;
          this._handlingClick = false;
          this._groupList = [];
          this._domGroups = [];
     
          for (i in baseLayers) {
            this._addLayer(baseLayers[i], i);
          }
     
          for (i in groupedOverlays) {
            for (j in groupedOverlays[i]) {
              this._addLayer(groupedOverlays[i][j], j, i, true);
            }
          }
        },
     
        onAdd: function (map) {
          this._initLayout();
          this._update();
     
          map
              .on('layeradd', this._onLayerChange, this)
              .on('layerremove', this._onLayerChange, this);
     
          return this._container;
        },
     
        onRemove: function (map) {
          map
              .off('layeradd', this._onLayerChange, this)
              .off('layerremove', this._onLayerChange, this);
        },
     
        addBaseLayer: function (layer, name) {
          this._addLayer(layer, name);
          this._update();
          return this;
        },
     
        addOverlay: function (layer, name, group) {
          this._addLayer(layer, name, group, true);
          this._update();
          return this;
        },
     
        removeLayer: function (layer) {
          var id = L.Util.stamp(layer);
          var _layer = this._getLayer(id);
          if (_layer) {
            delete this._layers[this._layers.indexOf(_layer)];
          }
          this._update();
          return this;
        },
     
        _getLayer: function (id) {
          for (var i = 0; i < this._layers.length; i++) {
            if (this._layers[i] && L.stamp(this._layers[i].layer) === id) {
              return this._layers[i];
            }
          }
        },
     
        _initLayout: function () {
          var className = 'leaflet-control-layers',
            container = this._container = L.DomUtil.create('div', className);
     
          // Makes this work on IE10 Touch devices by stopping it from firing a mouseout event when the touch is released
          container.setAttribute('aria-haspopup', true);
     
          if (L.Browser.touch) {
            L.DomEvent.on(container, 'click', L.DomEvent.stopPropagation);
          } else {
            L.DomEvent.disableClickPropagation(container);
            L.DomEvent.on(container, 'wheel', L.DomEvent.stopPropagation);
          }
     
          var form = this._form = L.DomUtil.create('form', className + '-list');
     
          if (this.options.collapsed) {
            if (!L.Browser.android) {
              L.DomEvent
                  .on(container, 'mouseover', this._expand, this)
                  .on(container, 'mouseout', this._collapse, this);
            }
            var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container);
            link.href = '#';
            link.title = 'Layers';
     
            if (L.Browser.touch) {
              L.DomEvent
                  .on(link, 'click', L.DomEvent.stop)
                  .on(link, 'click', this._expand, this);
            } else {
              L.DomEvent.on(link, 'focus', this._expand, this);
            }
     
            this._map.on('click', this._collapse, this);
            // TODO keyboard accessibility
          } else {
            this._expand();
          }
     
          this._baseLayersList = L.DomUtil.create('div', className + '-base', form);
          this._separator = L.DomUtil.create('div', className + '-separator', form);
          this._overlaysList = L.DomUtil.create('div', className + '-overlays', form);
     
          container.appendChild(form);
        },
     
        _addLayer: function (layer, name, group, overlay) {
          var id = L.Util.stamp(layer);
     
          var _layer = {
            layer: layer,
            name: name,
            overlay: overlay
          };
          this._layers.push(_layer);
     
          group = group || '';
          var groupId = this._indexOf(this._groupList, group);
     
          if (groupId === -1) {
            groupId = this._groupList.push(group) - 1;
          }
     
          var exclusive = (this._indexOf(this.options.exclusiveGroups, group) !== -1);
     
          _layer.group = {
            name: group,
            id: groupId,
            exclusive: exclusive
          };
     
          if (this.options.autoZIndex && layer.setZIndex) {
            this._lastZIndex++;
            layer.setZIndex(this._lastZIndex);
          }
        },
     
        _update: function () {
          if (!this._container) {
            return;
          }
     
          this._baseLayersList.innerHTML = '';
          this._overlaysList.innerHTML = '';
          this._domGroups.length = 0;
     
          var baseLayersPresent = false,
            overlaysPresent = false,
            i, obj;
     
          for (var i = 0; i < this._layers.length; i++) {
            obj = this._layers[i];
            this._addItem(obj);
            overlaysPresent = overlaysPresent || obj.overlay;
            baseLayersPresent = baseLayersPresent || !obj.overlay;
          }
     
          this._separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none';
        },
     
        _onLayerChange: function (e) {
          var obj = this._getLayer(L.Util.stamp(e.layer)),
            type;
     
          if (!obj) {
            return;
          }
     
          if (!this._handlingClick) {
            this._update();
          }
     
          if (obj.overlay) {
            type = e.type === 'layeradd' ? 'overlayadd' : 'overlayremove';
          } else {
            type = e.type === 'layeradd' ? 'baselayerchange' : null;
          }
     
          if (type) {
            this._map.fire(type, obj);
          }
        },
     
        // IE7 bugs out if you create a radio dynamically, so you have to do it this hacky way
        _createRadioElement: function (name, checked) {
          var radioHtml = '<input type="radio" class="leaflet-control-layers-selector" name="' + name + '"';
          if (checked) {
            radioHtml += ' checked="checked"';
          }
          radioHtml += '/>';
     
          var radioFragment = document.createElement('div');
          radioFragment.innerHTML = radioHtml;
     
          return radioFragment.firstChild;
        },
     
        _addItem: function (obj) {
          var label = document.createElement('label'),
            input,
            checked = this._map.hasLayer(obj.layer),
            container,
            groupRadioName;
     
          if (obj.overlay) {
            if (obj.group.exclusive) {
              groupRadioName = 'leaflet-exclusive-group-layer-' + obj.group.id;
              input = this._createRadioElement(groupRadioName, checked);
            } else {
              input = document.createElement('input');
              input.type = 'checkbox';
              input.className = 'leaflet-control-layers-selector';
              input.defaultChecked = checked;
            }
          } else {
            input = this._createRadioElement('leaflet-base-layers', checked);
          }
     
          input.layerId = L.Util.stamp(obj.layer);
          input.groupID = obj.group.id;
          L.DomEvent.on(input, 'click', this._onInputClick, this);
     
          var name = document.createElement('span');
          name.innerHTML = ' ' + obj.name;
     
          label.appendChild(input);
          label.appendChild(name);
     
          if (obj.overlay) {
            container = this._overlaysList;
     
            var groupContainer = this._domGroups[obj.group.id];
     
            // Create the group container if it doesn't exist
            if (!groupContainer) {
              groupContainer = document.createElement('div');
              groupContainer.className = 'leaflet-control-layers-group';
              groupContainer.id = 'leaflet-control-layers-group-' + obj.group.id;
     
              var groupLabel = document.createElement('label');
              groupLabel.className = 'leaflet-control-layers-group-label';
     
              if (obj.group.name !== '' && !obj.group.exclusive) {
                // ------ add a group checkbox with an _onInputClickGroup function
                if (this.options.groupCheckboxes) {
                  var groupInput = document.createElement('input');
                  groupInput.type = 'checkbox';
                  groupInput.className = 'leaflet-control-layers-group-selector';
                  groupInput.groupID = obj.group.id;
                  groupInput.legend = this;
                  L.DomEvent.on(groupInput, 'click', this._onGroupInputClick, groupInput);
                  groupLabel.appendChild(groupInput);
                }
              }
     
              var groupName = document.createElement('span');
              groupName.className = 'leaflet-control-layers-group-name';
              groupName.innerHTML = obj.group.name;
              groupLabel.appendChild(groupName);
     
              groupContainer.appendChild(groupLabel);
              container.appendChild(groupContainer);
     
              this._domGroups[obj.group.id] = groupContainer;
            }
     
            container = groupContainer;
          } else {
            container = this._baseLayersList;
          }
     
          container.appendChild(label);
     
          return label;
        },
     
        _onGroupInputClick: function () {
          var i, input, obj;
     
          var this_legend = this.legend;
          this_legend._handlingClick = true;
     
          var inputs = this_legend._form.getElementsByTagName('input');
          var inputsLen = inputs.length;
     
          for (i = 0; i < inputsLen; i++) {
            input = inputs[i];
            if (input.groupID === this.groupID && input.className === 'leaflet-control-layers-selector') {
              input.checked = this.checked;
              obj = this_legend._getLayer(input.layerId);
              if (input.checked && !this_legend._map.hasLayer(obj.layer)) {
                this_legend._map.addLayer(obj.layer);
              } else if (!input.checked && this_legend._map.hasLayer(obj.layer)) {
                this_legend._map.removeLayer(obj.layer);
              }
            }
          }
     
          this_legend._handlingClick = false;
        },
     
        _onInputClick: function () {
          var i, input, obj,
            inputs = this._form.getElementsByTagName('input'),
            inputsLen = inputs.length;
     
          this._handlingClick = true;
     
          for (i = 0; i < inputsLen; i++) {
            input = inputs[i];
            if (input.className === 'leaflet-control-layers-selector') {
              obj = this._getLayer(input.layerId);
     
              if (input.checked && !this._map.hasLayer(obj.layer)) {
                this._map.addLayer(obj.layer);
              } else if (!input.checked && this._map.hasLayer(obj.layer)) {
                this._map.removeLayer(obj.layer);
              }
            }
          }
     
          this._handlingClick = false;
        },
     
        _expand: function () {
          L.DomUtil.addClass(this._container, 'leaflet-control-layers-expanded');
          // permits to have a scrollbar if overlays heighter than the map.
          var acceptableHeight = this._map._size.y - (this._container.offsetTop * 4);
          if (acceptableHeight < this._form.clientHeight) {
            L.DomUtil.addClass(this._form, 'leaflet-control-layers-scrollbar');
            this._form.style.height = acceptableHeight + 'px';
          }
        },
     
        _collapse: function () {
          this._container.className = this._container.className.replace(' leaflet-control-layers-expanded', '');
        },
     
        _indexOf: function (arr, obj) {
          for (var i = 0, j = arr.length; i < j; i++) {
            if (arr[i] === obj) {
              return i;
            }
          }
          return -1;
        }
      });
     
      L.control.groupedLayers = function (baseLayers, groupedOverlays, options) {
        return new L.Control.GroupedLayers(baseLayers, groupedOverlays, options);
      };
    j'ai testé avec groupCheckboxes: true

    mais ça me rejoute que 2 cases.

    En vous remerciant

  2. #2
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 144
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 144
    Points : 44 954
    Points
    44 954
    Par défaut
    Bonjour,
    c'est dans ton fichier CSS qu'il faut que tu cherches, si je ne m'abuse
    Code css : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    .leaflet-control-layers:not(.expanded)
    .leaflet-control-layers-title > span,
    .leaflet-control-layers:not(.expanded)
    .leaflet-control-layers-selector,
    .leaflet-control-layers:not(.expanded)
    .leaflet-control-layers-grouplabel {
        display: none;
    }
    au moins pour la partie affichage.

Discussions similaires

  1. Problème checkbox sur feuille excel
    Par Contrec dans le forum Macros et VBA Excel
    Réponses: 12
    Dernier message: 07/01/2009, 14h58
  2. Problème Checkbox and Datagrid
    Par midotoon dans le forum ASP.NET
    Réponses: 2
    Dernier message: 23/10/2008, 20h59
  3. problème checkbox et display:table
    Par Bubu017 dans le forum Struts 1
    Réponses: 1
    Dernier message: 18/07/2008, 12h42
  4. Problème avec Layer
    Par bugmenot dans le forum Dreamweaver
    Réponses: 4
    Dernier message: 08/10/2007, 23h34
  5. Problème checkBox vbScript/asp
    Par CosmicGirl dans le forum VBScript
    Réponses: 2
    Dernier message: 03/10/2007, 11h38

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo