mardi 17 septembre 2019

I created a layer control but no check boxes appear

Hello Stackoverflow people! This is my first post here and I am quite new to JavaScript in general so forgive me if I seem a little helpless.

I am right now creating a map with leaflet and want to use grouped layers with custom icons on the map and have the user check, which ones are shown on the map. I followed the guide on the leaflet website and it works pretty fine, except that in the control window on my map no checkboxes appear. Its just the plain key-text to click on and no checkbox next to it.

This is how I proceeded:

created custom Icons:

var IconName= new custom_marker({iconUrl: 'icon.svg'}),

created layer groups:

var LayerGroup = L.layerGroup();

Create some random data as marker:

L.marker([51.805638, 70.998907], {icon: IconName}).addTo(LayerGroup).bindPopup("<b>This is the marker!</b><br />Here all the information will be stored.").openPopup();

Finally create the overlay variable and the control

var overlays = {
    "Name": LayerGroup,

};


L.control.layers(null,overlays, {collapsed: false}).addTo(ecomap); 

I have not found anybody else having that problem and copied the procedure pretty much 1:1 from the examples. Help would be very appreciated!

Best regards, Nick




Aucun commentaire:

Enregistrer un commentaire