target に渡す要素は、呼び出し時点で DOM に存在している必要があります。destroy() を呼ぶと以降のメソッド呼び出しは無効になります。AccessInformation を使うコンストラクタは非推奨です。サービスID文字列を使う形式を使用してください。import * as GIA from '@ntj/gaia';
GIA.config.endpoint = 'https://mapscript.cld.dev.navitime.co.jp/gaia/';
const map = new GIA.Map('YOUR_SERVICE_ID', {
target: '#map',
center: new GIA.value.LatLng(35.6895, 139.6917),
zoomLevel: 12,
options: {
antialias: true,
}
});
map.setMapRotationEnabled(true);
map.setMapTiltEnabled(true);
map.setMaxTilt(45);
const target = document.querySelector('#map');
const resizeMapEvent = () => {
const height = target.clientHeight;
const width = target.clientWidth;
map.setClientSize(new GIA.value.Size(height, width));
};
window.addEventListener("resize", resizeMapEvent);
window.addEventListener("orientationchange", resizeMapEvent);
window.addEventListener('beforeunload', () => {
map.destroy();
});
new Map(id, settings)による地図インスタンスの生成と破棄 — 詳細な使用例