mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-28 13:15:30 +01:00
Add control for hide/show of component layers (only regions for now)
This commit is contained in:
parent
625b62fa36
commit
bfb12e4f81
@ -43,6 +43,12 @@ if (!Array.prototype.indexOf) {
|
||||
}
|
||||
}
|
||||
|
||||
var DynmapLayerControl = L.Control.Layers.extend({
|
||||
getPosition: function() {
|
||||
return L.Control.Position.TOP_LEFT;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var DynmapTileLayer = L.TileLayer.extend({
|
||||
_currentzoom: undefined,
|
||||
|
@ -41,6 +41,7 @@ DynMap.prototype = {
|
||||
inittime: new Date().getTime(),
|
||||
followingPlayer: '',
|
||||
missedupdates: 0,
|
||||
layercontrol: undefined,
|
||||
formatUrl: function(name, options) {
|
||||
var url = this.options.url[name];
|
||||
$.each(options, function(n,v) {
|
||||
@ -137,6 +138,9 @@ DynMap.prototype = {
|
||||
me.followPlayer(null);
|
||||
});*/
|
||||
|
||||
me.layercontrol = new DynmapLayerControl();
|
||||
map.addControl(me.layercontrol);
|
||||
|
||||
// Sidebar
|
||||
var panel;
|
||||
var sidebar;
|
||||
@ -319,7 +323,8 @@ DynMap.prototype = {
|
||||
var prevzoom = me.map.getZoom();
|
||||
|
||||
if (me.maptype) {
|
||||
me.map.removeLayer(me.maptype);
|
||||
me.layercontrol.removeLayer(me.maptype);
|
||||
//me.map.removeLayer(me.maptype);
|
||||
}
|
||||
|
||||
var prevmap = me.maptype;
|
||||
@ -356,6 +361,7 @@ DynMap.prototype = {
|
||||
me.map.setZoom(prevzoom);
|
||||
}
|
||||
me.map.addLayer(me.maptype);
|
||||
//me.layercontrol.addBaseLayer(me.maptype, 'Tiles');
|
||||
|
||||
if (worldChanged) {
|
||||
$(me).trigger('worldchanged');
|
||||
|
@ -165,6 +165,7 @@ componentconstructors['regions'] = function(dynmap, configuration) {
|
||||
var activeLayer = undefined;
|
||||
function undraw() {
|
||||
if (activeLayer) {
|
||||
dynmap.layercontrol.removeLayer(activeLayer);
|
||||
dynmap.map.removeLayer(activeLayer);
|
||||
activeLayer = undefined;
|
||||
}
|
||||
@ -183,6 +184,7 @@ componentconstructors['regions'] = function(dynmap, configuration) {
|
||||
result: function(regionsLayer) {
|
||||
activeLayer = regionsLayer;
|
||||
dynmap.map.addLayer(activeLayer);
|
||||
dynmap.layercontrol.addOverlay(activeLayer, regionType);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user