Plus Codes!

This commit is contained in:
Crawlerop 2021-11-24 20:07:07 +07:00 committed by GitHub
parent c0516f6042
commit 49d375c374
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,7 @@
<html>
<head>
<title>MapAds search</title>
<script src="https://cdn.jsdelivr.net/openlocationcode/latest/openlocationcode.js"></script>
</head>
<body>
<noscript>Please enable the javascript for the search function to work!</noscript>
@ -80,7 +81,9 @@
"Jewellery Quarter is full of Diamonds!",
"Somebody could have played Minecraft with Rocketts Landing mod (aka Advanced Rocketry) installed!",
"Large Cities (eg Tokyo) = So many ads!",
"Our next library awaits!"
"Our next library awaits!",
//"Plus Codes! Try 5R4HCXQ3+J9R!"
"Plus Codes! Try 87G8P2J7+69R!"
]
const urls = {
@ -105,20 +108,27 @@
document.getElementById("search3").onclick = function() {
if (document.getElementById("search2").value != "") {
if (document.getElementById("search2").value.startsWith("geo:")) { // geo:35.335992,-79.038636
lval = document.getElementById("search2").value
let seq = document.getElementById("search2").value;
if (document.getElementById("search2").value.indexOf("+") != -1) {
let res = OpenLocationCode.decode(document.getElementById("search2").value);
seq = `geo:${res.latitudeCenter},${res.longitudeCenter}`;
}
if (seq.startsWith("geo:")) { // geo:35.335992,-79.038636
lval = seq
lpos = lval.split(":")[1]
ll = lpos.split(",")
xhr.open("GET",urls[document.getElementById("search4").value].replace("(query)", ll[1]+","+ll[0]) + (document.getElementById("search5").checked ? "&fuzzyMatch=false" : ""))
} else {
xhr.open("GET",urls[document.getElementById("search4").value].replace("(query)", document.getElementById("search2").value) + (document.getElementById("search5").checked ? "&fuzzyMatch=false" : ""))
xhr.open("GET",urls[document.getElementById("search4").value].replace("(query)", seq) + (document.getElementById("search5").checked ? "&fuzzyMatch=false" : ""))
}
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status <= 399) {
o = ""
rs = JSON.parse(this.responseText)
rs.features.forEach(function(feature){
o += `<a href="mapads_marker.html?localads=true&lat=`+feature.center[1]+`&lng=`+feature.center[0]+`"">`+feature.place_name+` - `+feature.center[1]+`, `+feature.center[0]+`</a> - <a href="mapads_marker.html?cors=true&localads=true&lat=`+feature.center[1]+`&lng=`+feature.center[0]+`">CORS</a> - <button onclick="navigator.clipboard.writeText('`+feature.center[1]+", "+feature.center[0]+`')">Copy Coords</button> - <button onclick="navigator.clipboard.writeText('geo:`+feature.center[1]+","+feature.center[0]+`')">Copy geoURI</button><br>`
o += `<a href="mapads_marker.html?localads=true&lat=`+feature.center[1]+`&lng=`+feature.center[0]+`">`+feature.place_name+` (`+OpenLocationCode.encode(feature.center[1], feature.center[0], OpenLocationCode.CODE_PRECISION_EXTRA)+`) `+` - `+feature.center[1]+`, `+feature.center[0]+`</a> - <a href="mapads_marker.html?cors=true&localads=true&lat=`+feature.center[1]+`&lng=`+feature.center[0]+`">CORS</a> - <button onclick="navigator.clipboard.writeText('`+feature.center[1]+", "+feature.center[0]+`')">Copy Coords</button> - <button onclick="navigator.clipboard.writeText('geo:`+feature.center[1]+","+feature.center[0]+`')">Copy geoURI</button><br>`
})
res.innerHTML = o
//console.log(res.innerHTML)