Mudanças entre as edições de "Predefinição:MapViewer"

De Wiki Gla
Ir para navegação Ir para pesquisar
(ajustando a predefinição)
Linha 1: Linha 1:
<includeonly>
<includeonly><div id="map-container-{{{id|mapa1}}}" class="mapa-viewer" style="width:{{{largura|100%}}}; height:{{{altura|500px}}}; background:#0f172a; border-radius:12px; overflow:hidden; position:relative;">
<div id="mw-map-viewer-{{{id|default}}}" style="width: {{{width|100%}}}; height: {{{height|500px}}};"></div>
    <div style="position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); color:#64748b;">
        ⏳ Carregando mapa...
    </div>
</div>
 
<script>
<script>
(function() {
(function() {
     // Injetar estilos
     // Configuração do mapa
     if (typeof window.MWMapViewerStyles !== 'undefined' && !document.getElementById('mw-map-viewer-styles')) {
     var configJSON = `{{{config}}}`;
        var styleTag = document.createElement('style');
    var containerId = 'map-container-{{{id|mapa1}}}';
        styleTag.id = 'mw-map-viewer-styles';
     var mapConfig = null;
        styleTag.innerHTML = window.MWMapViewerStyles;
        document.head.appendChild(styleTag);
    }
   
    // Carregar configuração
    var configStr = '{{{config|}}}';
     var config = {};
      
      
     try {
     try {
         config = JSON.parse(configStr);
         mapConfig = JSON.parse(configJSON);
     } catch(e) {
     } catch(e) {
         console.error('Erro ao parsear configuração do mapa:', e);
         console.error('Erro ao parsear config:', e);
         config = {
         document.getElementById(containerId).innerHTML = '<div style="padding:20px; text-align:center; color:#ef4444;">❌ Erro na configuração do mapa</div>';
            mapConfig: { initialFloor: 0, defaultZoom: 1, minZoom: 0.5, maxZoom: 3, zoomStep: 0.1 },
        return;
             layers: []
    }
   
    // Inicializar viewer quando a página carregar
    if (typeof window.MapViewer === 'undefined') {
        // Carregar o script do viewer
        var script = document.createElement('script');
        script.src = 'https://cdn.jsdelivr.net/gh/seu-usuario/map-viewer@latest/viewer.min.js';
        script.onload = function() {
             new window.MapViewer(containerId, mapConfig);
         };
         };
        document.head.appendChild(script);
    } else {
        new window.MapViewer(containerId, mapConfig);
     }
     }
   
    // Aguardar DOM carregar
    var containerId = 'mw-map-viewer-{{{id|default}}}';
    var checkExist = setInterval(function() {
        var container = document.getElementById(containerId);
        if (container && typeof window.MWMapViewer !== 'undefined') {
            clearInterval(checkExist);
            new window.MWMapViewer(container, config, {
                width: '{{{width|100%}}}',
                height: '{{{height|500px}}}'
            });
        }
    }, 100);
})();
})();
</script>
</script></includeonly>
 
</includeonly>
<noinclude>
{{documentation}}
</noinclude>

Edição das 09h36min de 8 de abril de 2026