-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3adaa6
commit 1b10a03
Showing
1 changed file
with
87 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,107 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>TZF Server Clickable Debugger</title> | ||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" /> | ||
<style> | ||
html, body, #map { | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="map"></div> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>TZF Server Clickable Debugger</title> | ||
<link | ||
rel="stylesheet" | ||
href="https://unpkg.com/[email protected]/dist/leaflet.css" | ||
/> | ||
<style> | ||
html, | ||
body, | ||
#map { | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="map"></div> | ||
|
||
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script> | ||
<script src="https://unpkg.com/[email protected]/dist/axios.min.js"></script> | ||
<script> | ||
var map = L.map('map').setView([40.7128, -74.0060], 5); | ||
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script> | ||
<script src="https://unpkg.com/[email protected]/dist/axios.min.js"></script> | ||
<script> | ||
var southWest = L.latLng(-90, -180); | ||
var northEast = L.latLng(90, 180); | ||
var bounds = L.latLngBounds(southWest, northEast); | ||
var map = L.map("map", { | ||
maxBounds: bounds, | ||
maxBoundsViscosity: 1, | ||
worldCopyJump: true, | ||
maxZoom: 18, | ||
minZoom: 3, | ||
}).setView([40.7128, -74.006], 5); | ||
|
||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | ||
maxZoom: 19, | ||
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors' | ||
}).addTo(map); | ||
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { | ||
maxZoom: 19, | ||
attribution: | ||
'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors', | ||
}).addTo(map); | ||
|
||
var markers = []; | ||
var polygons = []; | ||
var markers = []; | ||
var polygons = []; | ||
|
||
map.on('click', function(e) { | ||
var lng = e.latlng.wrap().lng.toFixed(4); | ||
var lat = e.latlng.wrap().lat.toFixed(4); | ||
map.on("click", function (e) { | ||
var lng = e.latlng.wrap().lng.toFixed(4); | ||
var lat = e.latlng.wrap().lat.toFixed(4); | ||
|
||
axios.get('/api/v1/tz', { | ||
params: { | ||
lng: lng, | ||
lat: lat | ||
} | ||
}) | ||
.then(function(response) { | ||
var timezone = response.data.timezone; | ||
var abbreviation = response.data.abbreviation; | ||
var offset = response.data.offset; | ||
var popupContent = ` | ||
axios | ||
.get("/api/v1/tz", { | ||
params: { | ||
lng: lng, | ||
lat: lat, | ||
}, | ||
}) | ||
.then(function (response) { | ||
var timezone = response.data.timezone; | ||
var abbreviation = response.data.abbreviation; | ||
var offset = response.data.offset; | ||
var popupContent = ` | ||
<b>Timezone:</b> ${timezone}<br> | ||
<b>Abbreviation:</b> ${abbreviation}<br> | ||
<b>Offset:</b> ${offset}<br> | ||
<b>Latitude:</b> ${lat}<br> | ||
<b>Longitude:</b> ${lng} | ||
`; | ||
|
||
var marker = L.marker(e.latlng).addTo(map); | ||
marker.bindPopup(popupContent).openPopup(); | ||
markers.push(marker); | ||
}) | ||
.catch(function(error) { | ||
console.error(error); | ||
}); | ||
var marker = L.marker(e.latlng).addTo(map); | ||
marker.bindPopup(popupContent).openPopup(); | ||
markers.push(marker); | ||
}) | ||
.catch(function (error) { | ||
console.error(error); | ||
}); | ||
|
||
axios.get('/api/v1/tz/geojson', { | ||
params: { | ||
lng: lng, | ||
lat: lat | ||
} | ||
}) | ||
.then(function(response) { | ||
var tzid = response.data.properties.tzid; | ||
if (!isPolygonAdded(tzid)) { | ||
var geojson = L.geoJSON(response.data).addTo(map); | ||
polygons.push({tzid: tzid, geojson: geojson}); | ||
} | ||
}) | ||
.catch(function(error) { | ||
console.error(error); | ||
axios | ||
.get("/api/v1/tz/geojson", { | ||
params: { | ||
lng: lng, | ||
lat: lat, | ||
}, | ||
}) | ||
.then(function (response) { | ||
var tzid = response.data.properties.tzid; | ||
if (!isPolygonAdded(tzid)) { | ||
var geojson = L.geoJSON(response.data).addTo(map); | ||
polygons.push({ tzid: tzid, geojson: geojson }); | ||
} | ||
}) | ||
.catch(function (error) { | ||
console.error(error); | ||
}); | ||
}); | ||
}); | ||
|
||
function isPolygonAdded(tzid) { | ||
for (var i = 0; i < polygons.length; i++) { | ||
if (polygons[i].tzid === tzid) { | ||
return true; | ||
function isPolygonAdded(tzid) { | ||
for (var i = 0; i < polygons.length; i++) { | ||
if (polygons[i].tzid === tzid) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
return false; | ||
} | ||
</script> | ||
</body> | ||
</script> | ||
</body> | ||
</html> |