-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
48 lines (45 loc) · 1.87 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
<!DOCTYPE html>
<html>
<head>
<title>OpenStreetMapとLeafletで地図を表示する</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
crossorigin="" />
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
crossorigin=""></script>
</head>
<body>
<div id="view_map" style="height: 100vh;"></div>
<script type="text/javascript">
//緯度,経度,ズーム
var map = L.map('view_map').setView([35.1709732, 136.9310982], 11);
var popup = L.popup();
// OpenStreetMap から地図画像を読み込む
L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, '
}).addTo(map);
function makeMarker(lati, long, images, message){
var currentImageIndex = 0;
var imagePath = images[currentImageIndex];
var marker = L.marker([parseFloat(lati), parseFloat(long)]).addTo(map)
var popupContent = message + '<br /><img src="' + imagePath + '" alt="画像" /><br />';
var popupOptions = {
maxWidth: "auto"
};
marker.bindPopup(popupContent, popupOptions);
}
makeMarker(35.658577, 139.745451, ["Data/49656640.jpg"], "ここにメッセージを表示");
</script>
</body>
</html>