how to bound markers with base layers : leaflet

المشرف العام

Administrator
طاقم الإدارة
I been working with leaflet control and here i stuck for a while....

I have multiple base layers, and user can toggle between theselayers. these layers have separate drawing controls.

When i add markers on one layer(for example : layer1), then it is alsovisible on other layers(layers added dynamically later on).

My question is, how can we put marker on layer which will strictlybound for it only e.g: layer1

Script

//Custom control for markerL.easyButton('fa-arrow', function () {map.on('click', function arrow(e) {L.marker(e.latlng, { icon: arrIcon, draggable: true}).addTo(map);map.off('click', camerasPlace);});}).addTo(map);//already added layer and needs to bind marker with thisvar layerGroup = new L.LayerGroup(),imageOverlayUrl = 'assets/img/isbimg.jpg',imageOverlay = new L.ImageOverlay(imageOverlayUrl, bounds).addTo(layerGroup),featureGroup = new L.FeatureGroup().addTo(layerGroup);var layerGroupings = { "Main": layerGroup };var layerControl = new L.control.layers(layerGroupings,null, { collapsed: false }).addTo(map);In short, i have to bound custom marker control with my this layergroup i mentioned, it should not appear on other layers.

Any type of reference or help will be appreciated.



أكثر...
 
أعلى