-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
101 lines (73 loc) · 3.25 KB
/
index.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Leaflet Hello World">
<title>Leaflet Hello World</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
crossorigin=""/>
<!-- Make sure you put this AFTER Leaflet's CSS -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
crossorigin=""></script>
</head>
<style>
#body {
margin: 0px;
padding: 0px;
}
html,
body,
#mapid {
height: 100%;
width: 100%;
margin: 0px;
}
</style>
<body>
<div id="mapid"></div>
<script>
var mymap = L.map('mapid').setView([23.7, 121], 6);
//L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
//maxZoom: 18,
//attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
//'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + 'Imagery (c) <a href="https://www.mapbox.com/">Mapbox</a>',
//id: 'mapbox.streets'
//}).addTo(mymap);
L.marker([25.025735, 121.526413], {
draggable:true,
autoPan: true,
autoPanPadding: [200, 200],
autoPanSpeed: 25
}).addTo(mymap);
var baselayers = {
'OpenStreetMap.Mapnik': L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'),
'OpenStreetMap.DE': L.tileLayer('https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png'),
'OpenStreetMap.CH': L.tileLayer('https://tile.osm.ch/switzerland/{z}/{x}/{y}.png'),
'OpenStreetMap.France': L.tileLayer('https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png'),
'OpenStreetMap.HOT': L.tileLayer('https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png'),
'OpenStreetMap.BZH': L.tileLayer('https://tile.openstreetmap.bzh/br/{z}/{x}/{y}.png'),
'OpenTopoMap': L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png'),
'Thunderforest_SpinalMap': L.tileLayer('https://{s}.tile.thunderforest.com/spinal-map/{z}/{x}/{y}.png'),
'1956_Landuse': L.tileLayer('https://gis.sinica.edu.tw/tileserver/file-exists.php?img=1956_Landuse-png-{z}-{x}-{y}'),
'全島數值地形多向陰影圖': L.tileLayer('https://landslide.geologycloud.tw/jlwmts/jetlink/Shadw20/GoogleMapsCompatible/{z}/{x}/{y}'),
};
var overlays = {};
L.control.layers(baselayers, overlays).addTo(mymap);
baselayers['OpenStreetMap.Mapnik'].addTo(mymap);
const popup = L.popup();
function onMapClick(e) {
let lat = e.latlng.lat; // 緯度
let lng = e.latlng.lng; // 經度
popup
.setLatLng(e.latlng)
.setContent(`緯度:${lat}<br/>經度:${lng}`)
.openOn(mymap);
}
mymap.on('click', onMapClick);
</script>
</body>
</html>