「Widget:Custom map」の版間の差分

提供:メタファー リファンタジオ 攻略Wiki
移動先:案内検索
編集の要約なし
編集の要約なし
1行目: 1行目:
<div id="map" style="height: 600px;"></div>
<script>
<script>
mw.loader.using('ext.leafletmapsWidget').then(function() {
(function() {
     // ここにスクリプトが正しくロードされた後の処理を記述
    // Load required styles
     console.log('leafletmaps-widget.js has been loaded successfully.');
    const styles = [
     initLeafletMap(); // 必要な初期化関数をここで呼び出す
        "https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.css",
}).catch(function(err) {
        "https://unpkg.com/leaflet@1.9.4/dist/leaflet.css",
    console.error('Failed to load leafletmaps-widget.js:', err);
        "https://dq.h1g.jp/img/dq10_offline/map/css/leaflet-easy-button.css",
});
        "https://dq.h1g.jp/img/dq10_offline/map/css/leaflet-tag-filter-button.css",
        "https://dq.h1g.jp/img/marker-icon-img/editable-popup.css",
        "https://dq.h1g.jp/img/lightgallery.min.css"
    ];
   
    styles.forEach(href => {
        const link = document.createElement('link');
        link.rel = 'stylesheet';
        link.href = href;
        document.head.appendChild(link);
    });
 
     // Load required scripts in order
     const scripts = [
        "https://code.jquery.com/jquery-3.7.1.min.js",
        "https://dq.h1g.jp/leaflet/leaflet.js",
        "https://dq.h1g.jp/img/dq10_offline/map/js/leaflet-easy-button.js",
        "https://dq.h1g.jp/img/dq10_offline/map/js/leaflet-tag-filter-button.js",
        "https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.js",
        "https://dq.h1g.jp/leaflet/custom-leaflet-draw-locale.js",
        "https://cdnjs.cloudflare.com/ajax/libs/lightgallery/2.7.2/lightgallery.min.js",
        "https://dq.h1g.jp/leaflet/leafletmaps-widget.js"  // メインのJavaScript実装
    ];
 
     function loadScriptSequentially(index) {
        if (index >= scripts.length) {
            // 全スクリプトのロードが完了したら初期化
            if (window.initLeafletMap) {
                window.initLeafletMap({
                    img: '<!--{$img}-->',
                    imgwidth: <!--{$imgwidth}-->,
                    imgheight: <!--{$imgheight}-->,
                    minzoom: <!--{$minzoom}-->,
                    maxzoom: <!--{$maxzoom}-->,
                    geojson: '<!--{$geojson}-->',
                    filters: {
                        filter1: '<!--{$filter1|default:"分類1"}-->',
                        filter2: '<!--{$filter2|default:"分類2"}-->',
                        filter3: '<!--{$filter3|default:"分類3"}-->',
                        filter4: '<!--{$filter4|default:"分類4"}-->',
                        filter5: '<!--{$filter5|default:"分類5"}-->',
                        filter6: '<!--{$filter6|default:"分類6"}-->'
                    }
                });
            }
            return;
        }
 
        const script = document.createElement('script');
        script.src = scripts[index];
        script.onload = () => loadScriptSequentially(index + 1);
        document.body.appendChild(script);
    }
 
    loadScriptSequentially(0);
})();
</script>
</script>

2024年11月10日 (日) 18:38時点における版

<script> (function() {

   // Load required styles
   const styles = [
       "https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.css",
       "https://unpkg.com/leaflet@1.9.4/dist/leaflet.css",
       "https://dq.h1g.jp/img/dq10_offline/map/css/leaflet-easy-button.css",
       "https://dq.h1g.jp/img/dq10_offline/map/css/leaflet-tag-filter-button.css",
       "https://dq.h1g.jp/img/marker-icon-img/editable-popup.css",
       "https://dq.h1g.jp/img/lightgallery.min.css"
   ];
   
   styles.forEach(href => {
       const link = document.createElement('link');
       link.rel = 'stylesheet';
       link.href = href;
       document.head.appendChild(link);
   });
   // Load required scripts in order
   const scripts = [
       "https://code.jquery.com/jquery-3.7.1.min.js",
       "https://dq.h1g.jp/leaflet/leaflet.js",
       "https://dq.h1g.jp/img/dq10_offline/map/js/leaflet-easy-button.js",
       "https://dq.h1g.jp/img/dq10_offline/map/js/leaflet-tag-filter-button.js",
       "https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.js",
       "https://dq.h1g.jp/leaflet/custom-leaflet-draw-locale.js",
       "https://cdnjs.cloudflare.com/ajax/libs/lightgallery/2.7.2/lightgallery.min.js",
       "https://dq.h1g.jp/leaflet/leafletmaps-widget.js"  // メインのJavaScript実装
   ];
   function loadScriptSequentially(index) {
       if (index >= scripts.length) {
           // 全スクリプトのロードが完了したら初期化
           if (window.initLeafletMap) {
               window.initLeafletMap({
                   img: ,
                   imgwidth: ,
                   imgheight: ,
                   minzoom: ,
                   maxzoom: ,
                   geojson: ,
                   filters: {
                       filter1: ,
                       filter2: ,
                       filter3: ,
                       filter4: ,
                       filter5: ,
                       filter6: 
                   }
               });
           }
           return;
       }
       const script = document.createElement('script');
       script.src = scripts[index];
       script.onload = () => loadScriptSequentially(index + 1);
       document.body.appendChild(script);
   }
   loadScriptSequentially(0);

})(); </script>