diff --git a/astronomy/lp2006/overlay/dark.html b/astronomy/lp2006/overlay/dark.html index aa55dbde..ddd1b498 100644 --- a/astronomy/lp2006/overlay/dark.html +++ b/astronomy/lp2006/overlay/dark.html @@ -4,6 +4,7 @@ Light Pollution Atlas 2006, 2016, 2020 and 2022 + @@ -31,6 +32,7 @@
+ @@ -145,6 +147,27 @@ L.control.scale({maxWidth: 200, position: 'topright'}).addTo(map); +var geocoder = L.Control.geocoder({ + defaultMarkGeocode: false +}) + .on('markgeocode', function(e) { + var center = e.geocode.center; + var lat = center.lat; + var lng = center.lng; + if( lat >= -80 && lat <= 80 && lng >= -360 && lng <= 360 ) { + var marker = L.marker([lat,lng], { + title: "Lat, Lon = "+lat+", "+lng, + opacity: 0.7 + }).addTo(map); + var zoom = Math.max( map.getZoom(), 8 ); + map.flyTo([lat, lng],zoom); + } else { + alert("\"" + lat + " " + lng + "\" is out of bounds:\r\n -80 <= lat <= 80 and\r\n -360 <= lon <= 360"); + } + }) + .addTo(map); + + map.on('overlayadd', function(eo) { if (eo.layer !== lightpollution2006) { if ( map.hasLayer(lightpollution2006) ) { @@ -180,57 +203,6 @@ } }); -// search box code -var searchbox = L.control.searchbox({ - position: 'topright', - expand: 'left', - width: '125px' -}).addTo(map); - -var message = "Lat, Lon, then Enter" - -searchbox.setValue(message) - -searchbox.onInput("keyup", function (e) { - var start = searchbox.getValue().replace(message,''); - searchbox.clear(); - searchbox.setValue(start); - if (e.keyCode == 13) { - if( searchbox.getValue() !== "") { - var values = searchbox.getValue().split(','); - var lat = values[0].replace(/[()]/g, ''); - var lng = values[1].replace(/[()]/g, ''); - if( !isNaN(lat) && !isNaN(lng) ) { - - if( lat >= -80 && lat <= 80 && lng >= -360 && lng <= 360 ) { - - var marker = L.marker([lat,lng], { - title: "Lat, Lon = "+lat+", "+lng, - opacity: 0.7 - - }).addTo(map); - var zoom = Math.max( map.getZoom(), 8 ); - map.flyTo([lat, lng],zoom); - searchbox.clear(); - searchbox.hide(); - } else { - alert("\"" + searchbox.getValue() + "\" is out of bounds:\r\n -80 <= lat <= 80 and\r\n -360 <= lon <= 360"); - searchbox.clear(); - searchbox.hide(); - } - } else { - alert("\"" + searchbox.getValue() + "\" is not a valid input\r\nType Lat, Lon, then Enter"); - searchbox.clear(); - searchbox.hide(); - - } - } else { - searchbox.clear(); - searchbox.hide(); - } - } -}); - map.on('click', function(e) { // get year of current displayed overlay diff --git a/astronomy/lp2016/overlay/dark.html b/astronomy/lp2016/overlay/dark.html index a875e18a..382d314f 100644 --- a/astronomy/lp2016/overlay/dark.html +++ b/astronomy/lp2016/overlay/dark.html @@ -4,6 +4,7 @@ Light Pollution Atlas 2006, 2016, 2020 and 2022 + @@ -31,6 +32,7 @@
+ @@ -145,6 +147,27 @@ L.control.scale({maxWidth: 200, position: 'topright'}).addTo(map); +var geocoder = L.Control.geocoder({ + defaultMarkGeocode: false +}) + .on('markgeocode', function(e) { + var center = e.geocode.center; + var lat = center.lat; + var lng = center.lng; + if( lat >= -80 && lat <= 80 && lng >= -360 && lng <= 360 ) { + var marker = L.marker([lat,lng], { + title: "Lat, Lon = "+lat+", "+lng, + opacity: 0.7 + }).addTo(map); + var zoom = Math.max( map.getZoom(), 8 ); + map.flyTo([lat, lng],zoom); + } else { + alert("\"" + lat + " " + lng + "\" is out of bounds:\r\n -80 <= lat <= 80 and\r\n -360 <= lon <= 360"); + } + }) + .addTo(map); + + map.on('overlayadd', function(eo) { if (eo.layer !== lightpollution2006) { if ( map.hasLayer(lightpollution2006) ) { @@ -180,57 +203,6 @@ } }); -// search box code -var searchbox = L.control.searchbox({ - position: 'topright', - expand: 'left', - width: '125px' -}).addTo(map); - -var message = "Lat, Lon, then Enter" - -searchbox.setValue(message) - -searchbox.onInput("keyup", function (e) { - var start = searchbox.getValue().replace(message,''); - searchbox.clear(); - searchbox.setValue(start); - if (e.keyCode == 13) { - if( searchbox.getValue() !== "") { - var values = searchbox.getValue().split(','); - var lat = values[0].replace(/[()]/g, ''); - var lng = values[1].replace(/[()]/g, ''); - if( !isNaN(lat) && !isNaN(lng) ) { - - if( lat >= -80 && lat <= 80 && lng >= -360 && lng <= 360 ) { - - var marker = L.marker([lat,lng], { - title: "Lat, Lon = "+lat+", "+lng, - opacity: 0.7 - - }).addTo(map); - var zoom = Math.max( map.getZoom(), 8 ); - map.flyTo([lat, lng],zoom); - searchbox.clear(); - searchbox.hide(); - } else { - alert("\"" + searchbox.getValue() + "\" is out of bounds:\r\n -80 <= lat <= 80 and\r\n -360 <= lon <= 360"); - searchbox.clear(); - searchbox.hide(); - } - } else { - alert("\"" + searchbox.getValue() + "\" is not a valid input\r\nType Lat, Lon, then Enter"); - searchbox.clear(); - searchbox.hide(); - - } - } else { - searchbox.clear(); - searchbox.hide(); - } - } -}); - map.on('click', function(e) { // get year of current displayed overlay diff --git a/astronomy/lp2020/overlay/dark.html b/astronomy/lp2020/overlay/dark.html index d7a54816..e013e43d 100644 --- a/astronomy/lp2020/overlay/dark.html +++ b/astronomy/lp2020/overlay/dark.html @@ -4,6 +4,7 @@ Light Pollution Atlas 2006, 2016, 2020 and 2022 + @@ -31,6 +32,7 @@
+ @@ -145,6 +147,27 @@ L.control.scale({maxWidth: 200, position: 'topright'}).addTo(map); +var geocoder = L.Control.geocoder({ + defaultMarkGeocode: false +}) + .on('markgeocode', function(e) { + var center = e.geocode.center; + var lat = center.lat; + var lng = center.lng; + if( lat >= -80 && lat <= 80 && lng >= -360 && lng <= 360 ) { + var marker = L.marker([lat,lng], { + title: "Lat, Lon = "+lat+", "+lng, + opacity: 0.7 + }).addTo(map); + var zoom = Math.max( map.getZoom(), 8 ); + map.flyTo([lat, lng],zoom); + } else { + alert("\"" + lat + " " + lng + "\" is out of bounds:\r\n -80 <= lat <= 80 and\r\n -360 <= lon <= 360"); + } + }) + .addTo(map); + + map.on('overlayadd', function(eo) { if (eo.layer !== lightpollution2006) { if ( map.hasLayer(lightpollution2006) ) { @@ -180,57 +203,6 @@ } }); -// search box code -var searchbox = L.control.searchbox({ - position: 'topright', - expand: 'left', - width: '125px' -}).addTo(map); - -var message = "Lat, Lon, then Enter" - -searchbox.setValue(message) - -searchbox.onInput("keyup", function (e) { - var start = searchbox.getValue().replace(message,''); - searchbox.clear(); - searchbox.setValue(start); - if (e.keyCode == 13) { - if( searchbox.getValue() !== "") { - var values = searchbox.getValue().split(','); - var lat = values[0].replace(/[()]/g, ''); - var lng = values[1].replace(/[()]/g, ''); - if( !isNaN(lat) && !isNaN(lng) ) { - - if( lat >= -80 && lat <= 80 && lng >= -360 && lng <= 360 ) { - - var marker = L.marker([lat,lng], { - title: "Lat, Lon = "+lat+", "+lng, - opacity: 0.7 - - }).addTo(map); - var zoom = Math.max( map.getZoom(), 8 ); - map.flyTo([lat, lng],zoom); - searchbox.clear(); - searchbox.hide(); - } else { - alert("\"" + searchbox.getValue() + "\" is out of bounds:\r\n -80 <= lat <= 80 and\r\n -360 <= lon <= 360"); - searchbox.clear(); - searchbox.hide(); - } - } else { - alert("\"" + searchbox.getValue() + "\" is not a valid input\r\nType Lat, Lon, then Enter"); - searchbox.clear(); - searchbox.hide(); - - } - } else { - searchbox.clear(); - searchbox.hide(); - } - } -}); - map.on('click', function(e) { // get year of current displayed overlay diff --git a/astronomy/lp2022/overlay/dark.html b/astronomy/lp2022/overlay/dark.html index 85db4a54..7cc99724 100644 --- a/astronomy/lp2022/overlay/dark.html +++ b/astronomy/lp2022/overlay/dark.html @@ -4,6 +4,7 @@ Light Pollution Atlas 2006, 2016, 2020 and 2022 + @@ -31,6 +32,7 @@
+ @@ -145,6 +147,27 @@ L.control.scale({maxWidth: 200, position: 'topright'}).addTo(map); +var geocoder = L.Control.geocoder({ + defaultMarkGeocode: false +}) + .on('markgeocode', function(e) { + var center = e.geocode.center; + var lat = center.lat; + var lng = center.lng; + if( lat >= -80 && lat <= 80 && lng >= -360 && lng <= 360 ) { + var marker = L.marker([lat,lng], { + title: "Lat, Lon = "+lat+", "+lng, + opacity: 0.7 + }).addTo(map); + var zoom = Math.max( map.getZoom(), 8 ); + map.flyTo([lat, lng],zoom); + } else { + alert("\"" + lat + " " + lng + "\" is out of bounds:\r\n -80 <= lat <= 80 and\r\n -360 <= lon <= 360"); + } + }) + .addTo(map); + + map.on('overlayadd', function(eo) { if (eo.layer !== lightpollution2006) { if ( map.hasLayer(lightpollution2006) ) { @@ -180,57 +203,6 @@ } }); -// search box code -var searchbox = L.control.searchbox({ - position: 'topright', - expand: 'left', - width: '125px' -}).addTo(map); - -var message = "Lat, Lon, then Enter" - -searchbox.setValue(message) - -searchbox.onInput("keyup", function (e) { - var start = searchbox.getValue().replace(message,''); - searchbox.clear(); - searchbox.setValue(start); - if (e.keyCode == 13) { - if( searchbox.getValue() !== "") { - var values = searchbox.getValue().split(','); - var lat = values[0].replace(/[()]/g, ''); - var lng = values[1].replace(/[()]/g, ''); - if( !isNaN(lat) && !isNaN(lng) ) { - - if( lat >= -80 && lat <= 80 && lng >= -360 && lng <= 360 ) { - - var marker = L.marker([lat,lng], { - title: "Lat, Lon = "+lat+", "+lng, - opacity: 0.7 - - }).addTo(map); - var zoom = Math.max( map.getZoom(), 8 ); - map.flyTo([lat, lng],zoom); - searchbox.clear(); - searchbox.hide(); - } else { - alert("\"" + searchbox.getValue() + "\" is out of bounds:\r\n -80 <= lat <= 80 and\r\n -360 <= lon <= 360"); - searchbox.clear(); - searchbox.hide(); - } - } else { - alert("\"" + searchbox.getValue() + "\" is not a valid input\r\nType Lat, Lon, then Enter"); - searchbox.clear(); - searchbox.hide(); - - } - } else { - searchbox.clear(); - searchbox.hide(); - } - } -}); - map.on('click', function(e) { // get year of current displayed overlay