「Widget:Custom map」の版間の差分
提供:メタファー リファンタジオ 攻略Wiki
ヘイグ運営用アカウント (トーク | 投稿記録) 編集の要約なし |
ヘイグ運営用アカウント (トーク | 投稿記録) 編集の要約なし |
||
78行目: | 78行目: | ||
function loadScript(src) { | function loadScript(src) { | ||
return new Promise((resolve, reject) => { | return new Promise((resolve, reject) => { | ||
console.log('[Script Loader] Loading:', src); | |||
const script = document.createElement('script'); | const script = document.createElement('script'); | ||
script.src = src; | script.src = src; | ||
script.onload = () => { | script.onload = () => { | ||
console.log('[Script Loader] Successfully loaded:', src); | |||
if (src.includes('gtp8-core.js')) { | if (src.includes('gtp8-core.js')) { | ||
console.log('Core module check:', { | console.log('[Script Loader] Core module check:', { | ||
hasGTP8: !!window.GTP8, | hasGTP8: !!window.GTP8, | ||
initializeMap: window.GTP8?.initializeMap, | |||
functionType: typeof window.GTP8?.initializeMap | |||
}); | }); | ||
} | } | ||
resolve(); | resolve(); | ||
}; | }; | ||
script.onerror = reject; | script.onerror = (error) => { | ||
console.error('[Script Loader] Failed to load:', src, error); | |||
reject(new Error(`Failed to load ${src}`)); | |||
}; | |||
document.head.appendChild(script); | document.head.appendChild(script); | ||
}); | }); | ||
} | } | ||
console.log('[Script Loader] Starting script loading sequence'); | |||
return loadScript('https://dq.h1g.jp/leaflet/gtp8-core.js') | return loadScript('https://dq.h1g.jp/leaflet/gtp8-core.js') | ||
.then(() => { | .then(() => { | ||
if (typeof window.GTP8.initializeMap !== 'function') { | if (typeof window.GTP8?.initializeMap !== 'function') { | ||
throw new Error(' | console.error('[Script Loader] Core module not properly initialized:', { | ||
GTP8: window.GTP8, | |||
initializeMap: window.GTP8?.initializeMap | |||
}); | |||
throw new Error('Core module not properly initialized'); | |||
} | } | ||
return loadScript('https://dq.h1g.jp/leaflet/gtp8-icons.js'); | return loadScript('https://dq.h1g.jp/leaflet/gtp8-icons.js'); | ||
107行目: | 117行目: | ||
.then(() => loadScript('https://dq.h1g.jp/leaflet/gtp8-init.js')) | .then(() => loadScript('https://dq.h1g.jp/leaflet/gtp8-init.js')) | ||
.catch(error => { | .catch(error => { | ||
console.error('Script | console.error('[Script Loader] Loading sequence failed:', error); | ||
alert('モジュールの読み込みに失敗しました。'); | alert('モジュールの読み込みに失敗しました。\n詳細はコンソールを確認してください。'); | ||
}); | }); | ||
} | } | ||
114行目: | 124行目: | ||
// Start loading when document is ready | // Start loading when document is ready | ||
$(document).ready(() => { | $(document).ready(() => { | ||
console.log('[Main] Document ready, starting initialization'); | |||
loadScriptsSequentially().catch(error => { | loadScriptsSequentially().catch(error => { | ||
console.error('Initialization error:', error); | console.error('[Main] Initialization error:', error); | ||
}); | }); | ||
}); | }); | ||
</script> | </script> | ||
</includeonly> | </includeonly> |