-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.html
45 lines (42 loc) · 2.03 KB
/
map.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width'>
<title>Map</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.4.0/dist/leaflet.css" integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA==" crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.4.0/dist/leaflet.js" integrity="sha512-QVftwZFqvtRNi0ZyCtsznlKSWOStnDORoefr1enyq5mVL4tmKB3S/EnC3rRJcxCPavG10IcrVGSmPh6Qw5lwrg==" crossorigin=""></script>
</head>
<body style="margin:0;padding:0;">
<div id="maphome" style="width:100vw;height:100vh;"></div>
<script>
console.log('ok')
var getParams = function (url) {
var params = {};
var parser = document.createElement('a');
parser.href = url;
var query = parser.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
params[pair[0]] = decodeURIComponent(pair[1]);
}
return params;
};
var params = getParams(window.location.href);
const maptileurl = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}'
let latitude = -7.2484
let longitude = 112.7419
if(params.latitude)latitude = params.latitude
if(params.longitude)longitude = params.longitude
var map = L.map('maphome').setView([latitude, longitude], 7);
map.attributionControl.setPrefix('');
L.tileLayer(maptileurl, {
maxZoom: 18,
attribution: '',
id: 'mapbox.streets'
}).addTo(map);
L.marker([latitude, longitude]).addTo(map);
</script>
</body>
</html>