11export var DebugOverlay = L . Layer . extend ( {
22
33 onAdd : function ( map ) {
4- this . _container = L . DomUtil . create ( "div" , "mapml-debug" , map . _container ) ;
5-
6- //adds a control panel
7- /* this._controlPanel = L.DomUtil.create("div", "mapml-debug-control mapml-debug-panel", this._container);
8- let toggleGridBtn = document.createElement('button'), gridBtnText = document.createTextNode("Toggle Grid");
9- toggleGridBtn.appendChild(gridBtnText);
10- toggleGridBtn.overlay = this;
11- L.DomEvent.on(toggleGridBtn, 'click',this._toggleGrid);
12- this._controlPanel.appendChild(toggleGridBtn); */
4+
5+ let mapSize = map . getSize ( ) ;
6+
7+ //conditionally show container for debug panel/banner only when the map has enough space for it
8+ if ( mapSize . x > 400 || mapSize . y > 300 ) {
9+ this . _container = L . DomUtil . create ( "div" , "mapml-debug" , map . _container ) ;
10+
11+ //adds a control panel
12+ /* this._controlPanel = L.DomUtil.create("div", "mapml-debug-control mapml-debug-panel", this._container);
13+ let toggleGridBtn = document.createElement('button'), gridBtnText = document.createTextNode("Toggle Grid");
14+ toggleGridBtn.appendChild(gridBtnText);
15+ toggleGridBtn.overlay = this;
16+ L.DomEvent.on(toggleGridBtn, 'click',this._toggleGrid);
17+ this._controlPanel.appendChild(toggleGridBtn); */
18+
19+ this . _container . style . width = 150 ;
20+ this . _container . style . zIndex = 10000 ;
21+ this . _container . style . position = "absolute" ;
22+ this . _container . style . top = "auto" ;
23+ this . _container . style . bottom = "10px" ;
24+ this . _container . style . left = "10px" ;
25+ this . _container . style . right = "auto" ;
26+ }
1327
1428 this . _grid = debugGrid ( {
1529 className : "mapml-debug-grid" ,
@@ -56,17 +70,13 @@ export var DebugPanel = L.Layer.extend({
5670
5771 //conditionally show debug panel only when the map has enough space for it
5872 if ( mapSize . x > 400 || mapSize . y > 300 ) {
73+ this . _title = L . DomUtil . create ( "div" , "mapml-debug-banner" , this . options . pane ) ;
74+ this . _title . innerHTML = "Debug mode" ;
75+
5976 map . debug = { } ;
6077 map . debug . _infoContainer = this . _debugContainer = L . DomUtil . create ( "div" , "mapml-debug-panel" , this . options . pane ) ;
6178
6279 let infoContainer = map . debug . _infoContainer ;
63- infoContainer . style . zIndex = 10000 ;
64- infoContainer . style . width = 150 ;
65- infoContainer . style . position = "absolute" ;
66- infoContainer . style . top = "auto" ;
67- infoContainer . style . bottom = "4px" ;
68- infoContainer . style . right = "auto" ;
69- infoContainer . style . left = "4px" ;
7080
7181 map . debug . _tileCoord = L . DomUtil . create ( "div" , "mapml-debug-coordinates" , infoContainer ) ;
7282 map . debug . _tileMatrixCoord = L . DomUtil . create ( "div" , "mapml-debug-coordinates" , infoContainer ) ;
@@ -78,14 +88,6 @@ export var DebugPanel = L.Layer.extend({
7888 this . _map . on ( "mousemove" , this . _updateCoords ) ;
7989 }
8090
81- this . _title = L . DomUtil . create ( "div" , "mapml-debug-banner" , this . options . pane ) ;
82- this . _title . innerHTML = "DEBUG MODE" ;
83- this . _title . style . zIndex = 10000 ;
84- this . _title . style . position = "absolute" ;
85- this . _title . style . top = "4px" ;
86- this . _title . style . bottom = "auto" ;
87- this . _title . style . left = "auto" ;
88- this . _title . style . right = "4px" ;
8991 } ,
9092 onRemove : function ( ) {
9193 L . DomUtil . remove ( this . _title ) ;
0 commit comments