ソースファイルを表示

sample/sample_btn.htm

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1" /> <title>Leaflet 地図にボタンを表示</title> <link rel="stylesheet" href="js/leaflet.css" /> <script src="js/leaflet.js"></script> <style type="text/css"> #map_container {     position:absolute;     top:0; left:0; right:0; bottom:0; } #btn_container {     position:absolute;     left:12px; bottom:12px;     z-index: 1000; } </style> <script type="text/javascript" charset="UTF-8"> var map; // leaflet地図 var bound; // 表示領域(全体表示で表示される範囲) function init() {     map = L.map('map_container', { zoomControl: false });     L.tileLayer("https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png",{         attribution: "<a href='https://maps.gsi.go.jp/development/ichiran.html'"         + " target='_blank'>地理院標準地図</a>"     }).addTo(map); // 地理院地図を表示     L.control.scale({imperial:false, position:'bottomright'}).addTo(map); // 目盛表示     L.control.zoom({position:'bottomright'}).addTo(map); // ズーム制御     bound = [[31.0, 129.5], [45.5, 145.8]]; // 日本本土の範囲     map.fitBounds(bound); // 日本本土の範囲を表示 } </script> </head> <body onload="init()"> <div id="map_container"></div> <div id="btn_container">     <input type="button" onclick="map.fitBounds(bound)" value="全体表示" /> </div> </body> </html>