aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/ScheduleMap.astro18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/components/ScheduleMap.astro b/src/components/ScheduleMap.astro
index 82e37bf..0c509dd 100644
--- a/src/components/ScheduleMap.astro
+++ b/src/components/ScheduleMap.astro
@@ -13,14 +13,11 @@
<script>
import 'leaflet/dist/leaflet.css';
import type { Circle, LatLngTuple, LayerGroup, Marker } from 'leaflet';
- import facilities from '@/data/kodaira-facilities.json';
- import extraVenues from '@/data/kodaira-event-venues.json';
- import boundary from '@/data/kodaira-boundary.json';
type Venue = { name: string; alias: string; lat: number; lon: number };
type Entry = { name: string; time: string; category: string; rowId: string };
- function buildVenues(): Venue[] {
+ function buildVenues(facilities: any[], extraVenues: any[]): Venue[] {
const out: Venue[] = [];
// 「小川町一丁目地域センター」と「小川町1丁目」のような漢数字・算用数字の違いを吸収する。
const toAsciiDigits = (s: string) =>
@@ -54,7 +51,8 @@
return out.sort((a, b) => b.alias.length - a.alias.length);
}
- const venues = buildVenues();
+ // 会場データは地図を初期化するときに読み込む(初期表示では読まない)。
+ let venues: Venue[] = [];
const compact = (s: string) => s.replace(/[\s ]/g, '');
// 文章中の会場名を、左から順に・長い名前を優先して拾う。
@@ -95,8 +93,14 @@
const noteEl = document.getElementById('schedule-map-note');
async function initMap(el: HTMLElement, noteEl: HTMLElement) {
- // Leaflet はこの関数が呼ばれたときに初めて読み込む(別チャンクになる)。
- const L = (await import('leaflet')).default;
+ // Leaflet と会場データは、地図が画面に近づくまで読み込まない(別チャンクになる)。
+ const [L, facilities, extraVenues, boundary] = await Promise.all([
+ import('leaflet').then((mod) => mod.default),
+ import('@/data/kodaira-facilities.json').then((mod) => mod.default),
+ import('@/data/kodaira-event-venues.json').then((mod) => mod.default),
+ import('@/data/kodaira-boundary.json').then((mod) => mod.default),
+ ]);
+ venues = buildVenues(facilities, extraVenues);
const map = L.map(el, {
scrollWheelZoom: false,