OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Vue Leaflet adding a select / unselect all in Layer groups control

  • Thread starter Thread starter Jean-Loup
  • Start date Start date
J

Jean-Loup

Guest
I am using Vue.js 3, Leaflet and Vueleaflet. My map displays the layers groups containing markers (LLayerGroup) :

Map layers groups

I want to add "Select all" / "Unselect all" checkboxes at the top of the groups checkboxes. Is there a way to easily custom Layer and group control element in Vue Leaflet to achieve this ?

Here is my vue template code :

Code:
    <l-map
      :zoom="zoom" 
      :center="center" 
      :options="{ attributionControl: false }"
      @update:zoom="zoomUpdated" 
      @update:center="centerUpdated" 
      @update:bounds="boundsUpdated">
      <l-tile-layer
      v-for="tileProvider in tileProviders"
      :key="tileProvider.name"
      :name="tileProvider.name"
      :visible="tileProvider.visible"
      :url="tileProvider.url"
      layer-type="base"/>
      <l-control-layers position="topright"></l-control-layers>
      <l-layer-group
          v-for="bGroup in groupsMarkers" 
          :key="bGroup.groupId" layer-type="overlay" :name="bGroup.groupName" :visible="true">
              <MapMarker
              v-for="marker in bGroup.markers" 
              :key="marker.baliseId"
              :id="marker.baliseId"
              :name="marker.baliseName"
              />
      </l-layer-group>
    </l-map>

<p>I am using Vue.js 3, Leaflet and Vueleaflet.
My map displays the layers groups containing markers (<code>LLayerGroup</code>) :</p>
<p><a href="https://i.sstatic.net/zNuHo.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zNuHo.png" alt="Map layers groups" /></a></p>
<p>I want to add "Select all" / "Unselect all" checkboxes at the top of the groups checkboxes.
Is there a way to easily custom Layer and group control element in Vue Leaflet to achieve this ?</p>
<p>Here is my vue template code :</p>
<pre><code> <l-map
:zoom="zoom"
:center="center"
:options="{ attributionControl: false }"
@update:zoom="zoomUpdated"
@update:center="centerUpdated"
@update:bounds="boundsUpdated">
<l-tile-layer
v-for="tileProvider in tileProviders"
:key="tileProvider.name"
:name="tileProvider.name"
:visible="tileProvider.visible"
:url="tileProvider.url"
layer-type="base"/>
<l-control-layers position="topright"></l-control-layers>
<l-layer-group
v-for="bGroup in groupsMarkers"
:key="bGroup.groupId" layer-type="overlay" :name="bGroup.groupName" :visible="true">
<MapMarker
v-for="marker in bGroup.markers"
:key="marker.baliseId"
:id="marker.baliseId"
:name="marker.baliseName"
/>
</l-layer-group>
</l-map>
</code></pre>
 

Latest posts

M
Replies
0
Views
1
Muhammad Ikhwan Perwira
M
Top