Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

leaflet remove layergroup

// USE map.removeLayer( group );

var map = L.map('map').setView([44.646, 22.637], 12);
var layer = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
var group = L.layerGroup().addTo(map); // <=== CREATE
var marker1 = L.marker([44.64, 22.63]).addTo(group);
var marker2 = L.marker([44.65, 22.63]).addTo(group);

map.on('click', function() {
  map.removeLayer( group );	// <=== REMOVE
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: Find the index of an item in the Array 
Javascript :: js nuxt read/set cookie 
Javascript :: get all data attributes jquery from multiple elements 
Javascript :: javascript find matching elements in two arrays 
Javascript :: change image onclick javascript 
Javascript :: mongoose user model example 
Javascript :: get url of page in background script 
Javascript :: js get each pair of values from an array of objects 
Javascript :: flutter http get json to map 
Javascript :: SyntaxError: await is only valid in async function 
Javascript :: firebase.apps.length 
Javascript :: javascript how to remove the last character of the string 
Javascript :: get current location city name react native 
Javascript :: fetch data with axios in reactjs 
Javascript :: Javascript - find the largest 
Javascript :: Remove duplicate items in an array 
Javascript :: react native asign width to image 
Javascript :: how to comment out code in react js 
Javascript :: settimeout method 
Javascript :: js highest number in array 
Javascript :: how to write a test case for dropdown selection change in angular 9 
Javascript :: annotation 
Javascript :: useEffect in nextjs 
Javascript :: how to check what browser you are using 
Javascript :: delete dom elements 
Javascript :: javascript multidimensional array 
Javascript :: spread operator javascript 
Javascript :: getelementsbytagname 
Javascript :: como eliminar un elemento del dom con javascript 
Javascript :: Conditionally pass props to react component 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =