<!DOCTYPE html> <html> <head> <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"> <script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script> </head> <body> <div id="map"></div> </body> </html>
#map { height: 300px; }
var mymap = L.map('map'); L.tileLayer('https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png', { maxZoom: 18, attribution: '<a href="https://maps.gsi.go.jp/development/ichiran.html" target="_blank">国土地理院</a>', }).addTo(mymap); mymap.setView([37.508106, 139.930239], 13); var markerIcon = L.icon({ iconUrl: 'http://www.nowhere.co.jp/blog/wp-content/uploads/2018/07/marker.png', // アイコン画像のURL iconSize: [32, 32], // アイコンの大きさ iconAnchor: [16, 32], // 画像内でマーカーの位置を指し示す点の位置 popupAnchor: [0, -32] // ポップアップが出現する位置(iconAnchorからの相対位置) }); var marker = L.marker([37.508106, 139.930239], {icon: markerIcon}).addTo(mymap); marker.bindPopup("会津若松駅");