「Widget:Custom map」の版間の差分
提供:メタファー リファンタジオ 攻略Wiki
ヘイグ運営用アカウント (トーク | 投稿記録) 編集の要約なし |
ヘイグ運営用アカウント (トーク | 投稿記録) 編集の要約なし |
||
1行目: | 1行目: | ||
< | <!-- Required CSS and libraries... --> | ||
<!-- Global Configuration --> | |||
<script> | <script> | ||
// Initialize | // Clear any existing GTP8 object | ||
if (window.GTP8) { | |||
delete window.GTP8; | |||
} | |||
// Initialize fresh GTP8 namespace | |||
window.GTP8 = { | window.GTP8 = { | ||
map: null, | map: null, | ||
drawnItems: null, | drawnItems: null, | ||
18行目: | 24行目: | ||
const baseUrl = currentUrl.origin + currentUrl.pathname.split('/').slice(0, -1).join('/'); | const baseUrl = currentUrl.origin + currentUrl.pathname.split('/').slice(0, -1).join('/'); | ||
window.API_BASE_URL = baseUrl; | window.API_BASE_URL = baseUrl; | ||
console.log('API_BASE_URL initialized:', baseUrl); | |||
})(); | })(); | ||
// Map configuration | // Map configuration | ||
window.mapConfig = { | window.mapConfig = { | ||
imageUrl: '<!--{$img}-->', | imageUrl: '<!--{$img}-->', | ||
45行目: | 52行目: | ||
} | } | ||
}; | }; | ||
</script> | |||
<!-- Load scripts sequentially --> | |||
<script> | |||
function loadScriptsSequentially() { | |||
function loadScript(src) { | |||
return new Promise((resolve, reject) => { | |||
const script = document.createElement('script'); | |||
script.src = src; | |||
script.onload = resolve; | |||
script.onerror = reject; | |||
document.head.appendChild(script); | |||
}); | |||
} | |||
return loadScript('https://dq.h1g.jp/leaflet/gtp8-core.js') | |||
.then(() => { | |||
console.log('Core loaded:', typeof window.GTP8.initializeMap); | |||
return loadScript('https://dq.h1g.jp/leaflet/gtp8-icons.js'); | |||
}) | |||
.then(() => loadScript('https://dq.h1g.jp/leaflet/gtp8-popups.js')) | |||
.then(() => loadScript('https://dq.h1g.jp/leaflet/gtp8-api.js')) | |||
.then(() => loadScript('https://dq.h1g.jp/leaflet/gtp8-init.js')) | |||
.catch(error => { | |||
console.error('Script loading error:', error); | |||
}); | |||
} | |||
// | // Start loading when document is ready | ||
$(document).ready(() => { | |||
loadScriptsSequentially(); | |||
}); | }); | ||
</script> | </script> | ||
2024年11月10日 (日) 21:25時点における版
<script>
// Clear any existing GTP8 object
if (window.GTP8) {
delete window.GTP8;
}
// Initialize fresh GTP8 namespace window.GTP8 = {
map: null, drawnItems: null, drawControl: null, editMode: false, api: {}, popups: {}, icons: {}
};
// Initialize API base URL (function() {
const currentUrl = new URL(window.location.href); const baseUrl = currentUrl.origin + currentUrl.pathname.split('/').slice(0, -1).join('/'); window.API_BASE_URL = baseUrl; console.log('API_BASE_URL initialized:', baseUrl);
})();
// Map configuration window.mapConfig = {
imageUrl: , imageWidth: , imageHeight: , minZoom: , maxZoom: , geoJsonPage: , iconUrls: { icon1: , icon2: , icon3: , icon4: , icon5: , icon6: }, filters: { filter1: , filter2: , filter3: , filter4: , filter5: , filter6: }
}; </script>
<script> function loadScriptsSequentially() {
function loadScript(src) { return new Promise((resolve, reject) => { const script = document.createElement('script'); script.src = src; script.onload = resolve; script.onerror = reject; document.head.appendChild(script); }); }
return loadScript('https://dq.h1g.jp/leaflet/gtp8-core.js') .then(() => { console.log('Core loaded:', typeof window.GTP8.initializeMap); return loadScript('https://dq.h1g.jp/leaflet/gtp8-icons.js'); }) .then(() => loadScript('https://dq.h1g.jp/leaflet/gtp8-popups.js')) .then(() => loadScript('https://dq.h1g.jp/leaflet/gtp8-api.js')) .then(() => loadScript('https://dq.h1g.jp/leaflet/gtp8-init.js')) .catch(error => { console.error('Script loading error:', error); });
}
// Start loading when document is ready $(document).ready(() => {
loadScriptsSequentially();
}); </script>