-
Notifications
You must be signed in to change notification settings - Fork 2
/
gmap.php
35 lines (31 loc) · 1.05 KB
/
gmap.php
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
<!DOCTYPE html>
<html lang="zh">
<head>
<title>中文OpenStreetMap地圖顯示</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<style>
#map {
height: 400px;
width: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var latitude = <?=$_GET['latitude']?>; // 替換成你的緯度
var longitude = <?=$_GET['longitude']?>; // 替換成你的經度
var map = L.map('map').setView([latitude, longitude], 15);
// 使用支持中文的圖層
L.tileLayer('https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.marker([latitude, longitude]).addTo(map)
.bindPopup('我的位置')
.openPopup();
</script>
</body>
</html>