forked from ismyrnow/leaflet-groupedlayercontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding feature to make individual groups collapsable
ismyrnow#46 squashed + lint fixed Collapsable Groups. Added a config option "groupsCollapsable" which if set to true, will make each group header individually collapsable. This is useful when dealing with either small map elements, or a larger number of layers within the groups. Also added two supporting config settings: "groupsCollapseClass" and "groupsExpandClass" which control the css styles used for the toggle indicators, allowing users to override the default +/- indicators. Setting one to "glyphicon glyphicon-chevron-right" will use the glyphicon provided with bootstrap for example.
- Loading branch information
Showing
6 changed files
with
151 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Collapsable Example (Bootstrap Glyphicons)</title> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" /> | ||
<link rel="stylesheet" href="../src/leaflet.groupedlayercontrol.css" /> | ||
|
||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" /> | ||
|
||
</head> | ||
<body> | ||
<div id="map" style="width: 600px; height: 400px"></div> | ||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script> | ||
<script src="../src/leaflet.groupedlayercontrol.js"></script> | ||
<script src="exampledata.js"></script> | ||
<script> | ||
var map = L.map('map', { | ||
center: [39.73, -104.99], | ||
zoom: 10, | ||
layers: [ExampleData.Basemaps.Grayscale, ExampleData.LayerGroups.cities] | ||
}); | ||
|
||
// Overlay layers are grouped | ||
var groupedOverlays = { | ||
"Landmarks": { | ||
"Cities": ExampleData.LayerGroups.cities, | ||
"Restaurants": ExampleData.LayerGroups.restaurants | ||
}, | ||
"Random": { | ||
"Dogs": ExampleData.LayerGroups.dogs, | ||
"Cats": ExampleData.LayerGroups.cats | ||
} | ||
}; | ||
|
||
// Use the custom grouped layer control, not "L.control.layers" | ||
L.control.groupedLayers(ExampleData.Basemaps, groupedOverlays, {groupsCollapsable: true, groupsExpandedClass: "glyphicon glyphicon-chevron-down", groupsCollapsedClass: "glyphicon glyphicon-chevron-right"}).addTo(map); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Collapsable Example</title> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" /> | ||
<link rel="stylesheet" href="../src/leaflet.groupedlayercontrol.css" /> | ||
</head> | ||
<body> | ||
<div id="map" style="width: 600px; height: 400px"></div> | ||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script> | ||
<script src="../src/leaflet.groupedlayercontrol.js"></script> | ||
<script src="exampledata.js"></script> | ||
<script> | ||
var map = L.map('map', { | ||
center: [39.73, -104.99], | ||
zoom: 10, | ||
layers: [ExampleData.Basemaps.Grayscale, ExampleData.LayerGroups.cities] | ||
}); | ||
|
||
// Overlay layers are grouped | ||
var groupedOverlays = { | ||
"Landmarks": { | ||
"Cities": ExampleData.LayerGroups.cities, | ||
"Restaurants": ExampleData.LayerGroups.restaurants | ||
}, | ||
"Random": { | ||
"Dogs": ExampleData.LayerGroups.dogs, | ||
"Cats": ExampleData.LayerGroups.cats | ||
} | ||
}; | ||
|
||
// Use the custom grouped layer control, not "L.control.layers" | ||
L.control.groupedLayers(ExampleData.Basemaps, groupedOverlays, {groupsCollapsable: true}).addTo(map); | ||
</script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters