-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex1.html
84 lines (64 loc) · 2.64 KB
/
index1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Download GMaps Image</title>
<link rel="stylesheet" type="text/css" href="https://cdn.kukode.in/bootstrap/5/css/bootstrap.min.css">
</head>
<body class="bg-light">
<section>
<div class="container my-5">
<div class="row mx-1 bg-white shadow-sm rounded">
<div class="pt-3 pb-md-3 pb-0 col-md-6">
<input type="url" class="form-control" id="getUrl" placeholder="Url" onchange="getImgUrl(this.value)">
<a id="urlSource" class="d-none">urlSource</a>
</div>
<div class="py-3 col-md-6">
<img class="img-fluid rounded w-100" id="urlImg">
<div class="d-grid gap-2 d-none">
<a id="downLink" href="" class="btn btn-primary btn-block" download="img.jpg">Download Your File</a>
</div>
</div>
</div>
</div>
</section>
<!--
<script type="text/javascript" src="https://cdn.kukode.in/jquery/v3.5/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.kukode.in/bootstrap/5/js/bootstrap.bundle.min.js"></script>
-->
<script type="text/javascript">
// Example link https://www.google.com/local/imagery/report/?cb_client=maps_sv.tactile&image_key=!1e10!2sAF1QipPMOPUZo_qPa_aOKMTZUz_nSkFn4jZjulWidbfb&hl=en&gl=id&fid=0x2e7a59aa254f8a87%3A0x52eb6292bd557fdd
var defaultImage = 'https://mapandan.gov.ph/wp-content/uploads/2018/03/no_image.jpg';
function getImgUrl(text){
if (text !== '' || text !== ' ' || text !== null) {
document.getElementById("urlSource").href = text;
var anchor = document.getElementById("urlSource");
var queryString = anchor.search; // Returns:'?q=123'
// Further parsing:
let params = new URLSearchParams(queryString);
if (params.get("image_key") !== null) {
let q = params.get("image_key"); // is the number 123
let qSub = q.substr(8, q.length-1);
// document.getElementById("demo").innerHTML = qSub;
document.getElementById("urlImg").src = "https://lh3.googleusercontent.com/p/"+ qSub +"=s0";
// document.getElementById("downLink").href = "https://lh3.googleusercontent.com/p/"+ qSub +"=s0";
}
else if (params.get("imagekey") !== null) {
let q = params.get("imagekey"); // is the number 123
let qSub = q.substr(8, q.length-1);
// document.getElementById("demo").innerHTML = qSub;
document.getElementById("urlImg").src = "https://lh3.googleusercontent.com/p/"+ qSub +"=s0";
// document.getElementById("downLink").href = "https://lh3.googleusercontent.com/p/"+ qSub +"=s0";
}
else {
document.getElementById("urlImg").src = '';
}
}
else {
document.getElementById("urlImg").src = '';
}
}
</script>
</body>
</html>