-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLeafletGSI.js
31 lines (28 loc) · 1.06 KB
/
LeafletGSI.js
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
import L from "https://code4sabae.github.io/leaflet-mjs/leaflet.mjs";
import { LeafletSprite } from "https://taisukef.github.io/leaflet.sprite-es/src/sprite.js";
LeafletSprite.init(L);
const initMap = async (div) => {
//await loadCSS("https://code4sabae.github.io/leaflet-mjs/leaflet-grayscale.css");
await loadCSS("https://code4sabae.github.io/leaflet-mjs/leaflet.css");
const map = L.map(div);
// set 国土地理院地図 https://maps.gsi.go.jp/development/ichiran.html
L.tileLayer("https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png", {
attribution: '<a href="https://maps.gsi.go.jp/development/ichiran.html">国土地理院</a>',
maxZoom: 18,
}).addTo(map);
return map;
};
const loadCSS = async (css) => {
return new Promise((resolve) => {
const comp = document.body;
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = css;
comp.appendChild(link);
link.onload = () => resolve();
});
};
const LeafletGSI = {
initMap,
};
export { LeafletGSI }