ソースファイルを表示

sample/sample_svg.htm

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1" /> <title>Leafletで矢印のSVGデータを表示</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 = [[35.0, 135.0], [38.0, 140.0]]; // 日本中部の範囲     map.fitBounds(bound); // 日本中部の範囲を表示     let lay = L.layerGroup().addTo(map); // ベクターデータ表示領域     L.marker([36.55, 136.66], {icon: L.divIcon({ // SVGマーカを登録         html: '<svg xmlns="http://www.w3.org/2000/svg" width="300" height="300"><path \                 d="M0,-10 L50,-10 L50,-30 L90,0 L50,30 L50,10 L0,10 Z" \                 stroke="#ff0000" stroke-width="2" \                 fill="#ff7777" fill-opacity="0.3" \                 transform="translate(150, 150) rotate(0) scale(1)" \             ></path></svg>', // SVGデータ         iconSize: [0, 0], iconAnchor: [150, 150]     }) }).addTo(lay);     L.marker([36.55, 136.66], {icon: L.divIcon({ // SVGマーカを登録         html: '<svg xmlns="http://www.w3.org/2000/svg" width="300" height="300"><path \                 d="M0,-10 L50,-10 L50,-30 L90,0 L50,30 L50,10 L0,10 Z" \                 stroke="#0000ff" stroke-width="2" \                 fill="#7777ff" fill-opacity="0.3" \                 transform="translate(150, 150) rotate(-135) scale(0.8)" \             ></path></svg>', // SVGデータ         iconSize: [0, 0], iconAnchor: [150, 150]     }) }).addTo(lay); } </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>