@@ -15,6 +15,101 @@ L.control.scale({
1515 imperial : false
1616} ) . addTo ( map ) ;
1717
18+ // Add background menu control
19+ L . Control . BackgroundMenu = L . Control . extend ( {
20+ options : {
21+ position : 'topright'
22+ } ,
23+
24+ onAdd : function ( map ) {
25+ const container = L . DomUtil . create ( 'div' , 'leaflet-control-settings' ) ;
26+ container . style . position = 'relative' ;
27+
28+ const settingsBtn = L . DomUtil . create ( 'button' , 'leaflet-control-search-btn' , container ) ;
29+ settingsBtn . innerHTML = '⚙️' ;
30+ settingsBtn . title = 'Background Options' ;
31+ settingsBtn . onclick = ( ) => {
32+ const settingsMenu = container . querySelector ( '.settings' ) ;
33+ if ( settingsMenu . style . display === 'block' ) {
34+ settingsMenu . style . display = 'none' ;
35+ } else {
36+ settingsMenu . style . display = 'block' ;
37+ // Position settings menu to the left of the button
38+ settingsMenu . style . position = 'absolute' ;
39+ settingsMenu . style . top = `${ settingsBtn . offsetTop } px` ;
40+ settingsMenu . style . right = `${ container . offsetWidth - settingsBtn . offsetLeft + settingsBtn . offsetWidth } px` ;
41+ settingsMenu . style . width = '100px' ;
42+ settingsMenu . style . zIndex = '1000' ;
43+ }
44+ } ;
45+
46+ const settingsMenu = L . DomUtil . create ( 'div' , 'settings' , container ) ;
47+ settingsMenu . style . display = 'none' ; // hidden initially
48+
49+ // Create buttons in menu
50+ const normalBtn = L . DomUtil . create ( 'button' , '' , settingsMenu ) ;
51+ normalBtn . innerHTML = 'Normal' ;
52+ normalBtn . onclick = ( ) => {
53+ tileLayer . getContainer ( ) . style . filter = '' ;
54+ settingsMenu . style . display = 'none' ;
55+ } ;
56+
57+ const grayBtn = L . DomUtil . create ( 'button' , '' , settingsMenu ) ;
58+ grayBtn . innerHTML = 'Grayscale' ;
59+ grayBtn . onclick = ( ) => {
60+ tileLayer . getContainer ( ) . style . filter = 'grayscale(100%)' ;
61+ settingsMenu . style . display = 'none' ;
62+ } ;
63+
64+ const invertedBtn = L . DomUtil . create ( 'button' , '' , settingsMenu ) ;
65+ invertedBtn . innerHTML = 'Inverted' ;
66+ invertedBtn . onclick = ( ) => {
67+ tileLayer . getContainer ( ) . style . filter = 'grayscale(100%) invert(100%)' ;
68+ settingsMenu . style . display = 'none' ;
69+ } ;
70+
71+ return container ;
72+ }
73+ } ) ;
74+
75+ // Add search menu control
76+ L . Control . SearchMenu = L . Control . extend ( {
77+ options : {
78+ position : 'topright'
79+ } ,
80+
81+ onAdd : function ( map ) {
82+ const container = L . DomUtil . create ( 'div' , 'leaflet-control-search' ) ;
83+ container . style . position = 'relative' ;
84+
85+ const searchBtn = L . DomUtil . create ( 'button' , 'leaflet-control-search-btn' , container ) ;
86+ searchBtn . innerHTML = '🔍' ;
87+ searchBtn . title = 'Toggle Search Menu' ;
88+ searchBtn . onclick = ( ) => {
89+ const searchContainer = document . querySelector ( '.search-container' ) ;
90+ if ( searchContainer . style . display === 'block' ) {
91+ searchContainer . style . display = 'none' ;
92+ } else {
93+ searchContainer . style . display = 'block' ;
94+ // Position search menu to the left of the button
95+ searchContainer . style . position = 'absolute' ;
96+ searchContainer . style . top = `${ searchBtn . offsetTop } px` ;
97+ searchContainer . style . right = `${ container . offsetWidth - searchBtn . offsetLeft + searchBtn . offsetWidth } px` ;
98+ searchContainer . style . width = '200px' ;
99+ searchContainer . style . zIndex = '1000' ;
100+ }
101+ } ;
102+
103+ return container ;
104+ }
105+ } ) ;
106+
107+ // Add background menu control to map
108+ map . addControl ( new L . Control . BackgroundMenu ( ) ) ;
109+
110+ // Add search menu control to map
111+ map . addControl ( new L . Control . SearchMenu ( ) ) ;
112+
18113// Add screenshot control
19114L . Control . Screenshot = L . Control . extend ( {
20115 options : {
@@ -710,7 +805,6 @@ loadDataBtn.addEventListener('click', async function() {
710805 // Hide data selector and show slider and search
711806 document . querySelector ( '.data-selector' ) . style . display = 'none' ;
712807 document . querySelector ( '.slider-container' ) . style . display = 'block' ;
713- document . querySelector ( '.search-container' ) . style . display = 'block' ;
714808 } ) . catch ( error => {
715809 console . error ( "Error loading CSV files:" , error ) ;
716810 alert ( 'Error loading data files. Please check the console for details.' ) ;
0 commit comments