update several plugins to use window.addLayerGroup, instead of manually adding the layer to the map and Layer control.
this gives automatic handling of remembering shown/hidden layers also, draw tools plugin hides the controls while the drawn items layer is hidden
This commit is contained in:
parent
2f482bf4a4
commit
6e8dd15052
@ -119,14 +119,31 @@ window.plugin.drawTools.boot = function() {
|
|||||||
//create a leaflet FeatureGroup to hold drawn items
|
//create a leaflet FeatureGroup to hold drawn items
|
||||||
|
|
||||||
window.plugin.drawTools.drawnItems = new L.FeatureGroup();
|
window.plugin.drawTools.drawnItems = new L.FeatureGroup();
|
||||||
var drawnItems = window.plugin.drawTools.drawnItems;
|
|
||||||
|
|
||||||
window.layerChooser.addOverlay(drawnItems, 'Drawn Items');
|
|
||||||
map.addLayer(drawnItems);
|
|
||||||
|
|
||||||
//add the draw control - this references the above FeatureGroup for editing purposes
|
//add the draw control - this references the above FeatureGroup for editing purposes
|
||||||
plugin.drawTools.addDrawControl();
|
plugin.drawTools.addDrawControl();
|
||||||
|
|
||||||
|
//start off hidden. if the layer is enabled, the below addLayerGroup will add it, triggering a 'show'
|
||||||
|
$('.leaflet-draw-section').hide();
|
||||||
|
|
||||||
|
|
||||||
|
//hide the draw tools when the 'drawn items' layer is off, show it when on
|
||||||
|
map.on('layeradd', function(obj) {
|
||||||
|
if(obj.layer === window.plugin.drawTools.drawnItems) {
|
||||||
|
$('.leaflet-draw-section').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
map.on('layerremove', function(obj) {
|
||||||
|
if(obj.layer === window.plugin.drawTools.drawnItems) {
|
||||||
|
$('.leaflet-draw-section').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//add the layer
|
||||||
|
window.addLayerGroup('Drawn Items', window.plugin.drawTools.drawnItems);
|
||||||
|
|
||||||
|
|
||||||
|
//place created items into the specific layer
|
||||||
map.on('draw:created', function(e) {
|
map.on('draw:created', function(e) {
|
||||||
var type=e.layerType;
|
var type=e.layerType;
|
||||||
var layer=e.layer;
|
var layer=e.layer;
|
||||||
|
@ -116,7 +116,7 @@ window.plugin.maxLinks.setup = function() {
|
|||||||
window.plugin.maxLinks.updateLayer();
|
window.plugin.maxLinks.updateLayer();
|
||||||
});
|
});
|
||||||
window.map.on('zoomend moveend', window.plugin.maxLinks.updateLayer);
|
window.map.on('zoomend moveend', window.plugin.maxLinks.updateLayer);
|
||||||
window.layerChooser.addOverlay(window.plugin.maxLinks.layer, 'Maximum Links');
|
window.addLayerGroup('Maximum Links', window.plugin.maxLinks.layer);
|
||||||
}
|
}
|
||||||
var setup = window.plugin.maxLinks.setup;
|
var setup = window.plugin.maxLinks.setup;
|
||||||
|
|
||||||
|
@ -47,8 +47,7 @@ window.plugin.playerTracker.setup = function() {
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
plugin.playerTracker.drawnTraces = new L.LayerGroup();
|
plugin.playerTracker.drawnTraces = new L.LayerGroup();
|
||||||
window.layerChooser.addOverlay(plugin.playerTracker.drawnTraces, 'Player Tracker');
|
window.addLayerGroup('Player Tracker', plugin.playerTracker.drawnTraces);
|
||||||
map.addLayer(plugin.playerTracker.drawnTraces);
|
|
||||||
map.on('layeradd',function(obj) {
|
map.on('layeradd',function(obj) {
|
||||||
if(obj.layer === plugin.playerTracker.drawnTraces)
|
if(obj.layer === plugin.playerTracker.drawnTraces)
|
||||||
{
|
{
|
||||||
|
@ -77,8 +77,7 @@ var setup = function() {
|
|||||||
}")
|
}")
|
||||||
.appendTo("head");
|
.appendTo("head");
|
||||||
|
|
||||||
window.layerChooser.addOverlay(window.plugin.portalLevelNumbers.levelLayerGroup, 'Portal Levels');
|
window.addLayerGroup('Portal Levels', window.plugin.portalLevelNumbers.levelLayerGroup, true);
|
||||||
map.addLayer(window.plugin.portalLevelNumbers.levelLayerGroup);
|
|
||||||
|
|
||||||
window.addHook('portalAdded', window.plugin.portalLevelNumbers.portalAdded);
|
window.addHook('portalAdded', window.plugin.portalLevelNumbers.portalAdded);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user