Mudanças entre as edições de "Widget:MapViewer.js"
Ir para navegação
Ir para pesquisar
Etiqueta: Reversão manual |
|||
| Linha 1: | Linha 1: | ||
<includeonly> | <includeonly><div id="mapa-viewer-{{{id|mapa1}}}" class="mapa-container" style="width:{{{largura|100%}}}; height:{{{altura|500px}}}; background:#0f172a; border-radius:12px; overflow:hidden; position:relative;"> | ||
<div style="position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); color:#64748b; text-align:center;"> | <div style="position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); color:#64748b; text-align:center;"> | ||
<div>🗺️ Carregando mapa...</div> | <div>🗺️ Carregando mapa...</div> | ||
| Linha 13: | Linha 13: | ||
if (!container) return; | if (!container) return; | ||
// | // Receber configuração do template | ||
var | var configJSON = `{{{json}}}`; | ||
var mapConfig; | |||
try { | try { | ||
mapConfig = JSON.parse( | mapConfig = JSON.parse(configJSON); | ||
} catch(e) { | } catch(e) { | ||
container.innerHTML = '<div style="padding:20px; text-align:center; color:#ef4444;">❌ Erro na configuração do mapa | container.innerHTML = '<div style="padding:20px; text-align:center; color:#ef4444;">❌ Erro na configuração do mapa</div>'; | ||
console.error('Erro JSON:', e | console.error('Erro ao parsear JSON:', e); | ||
return; | return; | ||
} | } | ||
| Linha 103: | Linha 91: | ||
// Verificar se o andar atual existe | // Verificar se o andar atual existe | ||
if (!config.layers.find(function(l) { return l.id === currentFloor; })) { | |||
currentFloor = config.layers[0]?.id || 0; | |||
currentFloor = config.layers[0].id; | |||
} | } | ||
var floorAtual = | var floorAtual = config.layers.find(function(l) { return l.id === currentFloor; }); | ||
if (floorAtual && floorNameSpan) { | if (floorAtual && floorNameSpan) { | ||
floorNameSpan.textContent = floorAtual.name; | floorNameSpan.textContent = floorAtual.name; | ||
| Linha 160: | Linha 141: | ||
ctx.fillStyle = '#e0e0e0'; | ctx.fillStyle = '#e0e0e0'; | ||
ctx.font = '14px Arial'; | ctx.font = '14px Arial'; | ||
ctx.fillText(' | ctx.fillText('Clique em "Escolher imagem" no editor', 50, 150); | ||
img.src = canvas.toDataURL(); | img.src = canvas.toDataURL(); | ||
}; | }; | ||