「Widget:Custom map」の版間の差分
提供:メタファー リファンタジオ 攻略Wiki
ヘイグ運営用アカウント (トーク | 投稿記録) 編集の要約なし |
ヘイグ運営用アカウント (トーク | 投稿記録) 編集の要約なし |
||
75行目: | 75行目: | ||
<!-- Load scripts sequentially --> | <!-- Load scripts sequentially --> | ||
<script> | <script> | ||
// GTP8名前空間の初期化(最初に実行) | |||
window.GTP8 = { | |||
map: null, | |||
drawnItems: null, | |||
drawControl: null, | |||
editMode: false, | |||
api: {}, | |||
popups: {}, | |||
icons: {}, | |||
// 初期化関数のプレースホルダー | |||
initializeMap: null | |||
}; | |||
function loadScriptsSequentially() { | function loadScriptsSequentially() { | ||
function loadScript(src) { | function loadScript(src) { | ||
83行目: | 96行目: | ||
script.onload = () => { | script.onload = () => { | ||
console.log('[Script Loader] Successfully loaded:', src); | console.log('[Script Loader] Successfully loaded:', src); | ||
// core.jsの読み込み直後の検証 | |||
if (src.includes('gtp8-core.js')) { | if (src.includes('gtp8-core.js')) { | ||
console.log('[Script Loader] Core | const initializeMapType = typeof window.GTP8.initializeMap; | ||
console.log('[Script Loader] Core verification:', { | |||
hasGTP8: !!window.GTP8, | hasGTP8: !!window.GTP8, | ||
initializeMapType: initializeMapType, | |||
initializeMapString: window.GTP8.initializeMap?.toString() | |||
}); | }); | ||
if (initializeMapType !== 'function') { | |||
reject(new Error(`Invalid initializeMap type: ${initializeMapType}`)); | |||
return; | |||
} | |||
} | } | ||
resolve(); | resolve(); | ||
}; | }; | ||
script.onerror = (error) => | script.onerror = (error) => reject(new Error(`Failed to load ${src}: ${error}`)); | ||
document.head.appendChild(script); | document.head.appendChild(script); | ||
}); | }); | ||
} | } | ||
const scripts = [ | |||
'https://dq.h1g.jp/leaflet/gtp8-core.js', | |||
'https://dq.h1g.jp/leaflet/gtp8-icons.js', | |||
'https://dq.h1g.jp/leaflet/gtp8-popups.js', | |||
'https://dq.h1g.jp/leaflet/gtp8-api.js', | |||
'https://dq.h1g.jp/leaflet/gtp8-init.js' | |||
]; | |||
return scripts.reduce((promise, script) => { | |||
return promise.then(() => loadScript(script)); | |||
}, Promise.resolve()); | |||
} | } | ||
$(document).ready(() => { | $(document).ready(() => { | ||
console.log('[Main] | console.log('[Main] Starting initialization with GTP8 state:', window.GTP8); | ||
loadScriptsSequentially().catch(error => { | loadScriptsSequentially().catch(error => { | ||
console.error('[Main] | console.error('[Main] Loading sequence failed:', error); | ||
alert('モジュールの読み込みに失敗しました。\n詳細はコンソールを確認してください。'); | |||
}); | }); | ||
}); | }); | ||
</script> | </script> | ||
</includeonly> | </includeonly> |