{"id":3546,"date":"2026-04-10T09:32:43","date_gmt":"2026-04-10T09:32:43","guid":{"rendered":"https:\/\/greenleaf.agueda.pt\/?p=3546"},"modified":"2026-05-19T08:30:20","modified_gmt":"2026-05-19T08:30:20","slug":"teste-mapa","status":"publish","type":"post","link":"https:\/\/greenleaf.agueda.pt\/index.php\/2026\/04\/10\/teste-mapa\/","title":{"rendered":"Teste mapa"},"content":{"rendered":"\n<link rel=\"stylesheet\" href=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/leaflet\/1.9.4\/leaflet.min.css\">\n\n<style>\n#gl-map-section {\n  width: 100%;\n  max-width: 960px;\n  margin: 0 auto;\n  padding: 2rem 1rem;\n  box-sizing: border-box;\n  font-family: inherit;\n  position: relative;\n}\n#gl-map-title {\n  font-size: clamp(1.2rem, 2.5vw, 1.6rem);\n  font-weight: 600;\n  color: #1a2e0f;\n  margin: 0 0 0.4rem;\n}\n#gl-map-subtitle {\n  font-size: 0.95rem;\n  color: #556b44;\n  margin: 0 0 1.25rem;\n}\n#gl-map {\n  width: 100%;\n  height: 520px;\n  border-radius: 12px;\n  border: 1px solid #d4e4c0;\n  overflow: hidden;\n}\n@media (max-width: 600px) {\n  #gl-map {\n    height: 360px;\n  }\n}\n.gl-bottom-bar {\n  display: flex;\n  flex-direction: column;\n  align-items: stretch;\n  gap: 12px;\n  margin-top: 14px;\n}\n.gl-legend {\n  display: flex;\n  gap: 16px;\n  flex-wrap: wrap;\n  align-items: center;\n  flex: 1;\n}\n.gl-legend-item {\n  display: flex;\n  align-items: center;\n  gap: 7px;\n  font-size: 0.82rem;\n  color: #556b44;\n}\n.gl-legend-dot {\n  width: 13px;\n  height: 13px;\n  border-radius: 3px;\n  flex-shrink: 0;\n}\n.gl-cv-btn {\n  display: inline-flex;\n  align-items: center;\n  gap: 7px;\n  padding: 7px 14px;\n  background: #eaf3de;\n  border: 1px solid #c0dd97;\n  border-radius: 8px;\n  font-size: 0.82rem;\n  color: #3B6D11;\n  font-weight: 600;\n  cursor: pointer;\n  white-space: nowrap;\n  justify-content: center;\n  width: 100%;\n  transition: background 0.15s;\n  font-family: inherit;\n}\n.gl-cv-btn:hover {\n  background: #d4eab8;\n}\n.gl-cv-btn-dot {\n  width: 9px;\n  height: 9px;\n  border-radius: 50%;\n  background: #1D9E75;\n  flex-shrink: 0;\n}\n#gl-city-popup {\n  display: none;\n  position: absolute;\n  z-index: 1000;\n  background: #fff;\n  border: 1px solid #d4e4c0;\n  border-radius: 12px;\n  box-shadow: 0 4px 18px rgba(0,0,0,0.18);\n  width: 200px;\n  overflow: hidden;\n  pointer-events: auto;\n}\n#gl-city-popup img {\n  width: 100%;\n  height: 120px;\n  object-fit: cover;\n  display: block;\n}\n#gl-city-popup-footer {\n  padding: 8px 10px 9px;\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  background: #f6faef;\n}\n#gl-city-popup-name {\n  font-size: 0.85rem;\n  font-weight: 600;\n  color: #1a2e0f;\n}\n#gl-city-popup-close {\n  background: none;\n  border: none;\n  cursor: pointer;\n  font-size: 1rem;\n  color: #556b44;\n  line-height: 1;\n  padding: 0 2px;\n}\n.gl-pin-inner {\n  width: 12px;\n  height: 12px;\n  background: #1D9E75;\n  border: 2.5px solid #ffffff;\n  border-radius: 50%;\n  box-shadow: 0 1px 5px rgba(0,0,0,0.35);\n  cursor: pointer;\n}\n<\/style>\n\n<div id=\"gl-map-section\">\n  <h2 id=\"gl-map-title\">Os nossos destinos<\/h2>\n  <p id=\"gl-map-subtitle\">Pa\u00edses onde o \u00c1gueda Green Leaf j\u00e1 esteve presente<\/p>\n  <div id=\"gl-map\"><\/div>\n\n  <div id=\"gl-city-popup\">\n    <img decoding=\"async\" id=\"gl-city-popup-img\" src=\"\" alt=\"\">\n    <div id=\"gl-city-popup-footer\">\n      <span id=\"gl-city-popup-name\"><\/span>\n      <button id=\"gl-city-popup-close\" title=\"Fechar\">&#x2715;<\/button>\n    <\/div>\n  <\/div>\n\n  <div class=\"gl-bottom-bar\">\n    <div class=\"gl-legend\">\n      <div class=\"gl-legend-item\">\n        <div class=\"gl-legend-dot\" style=\"background:#3B6D11;\"><\/div>\n        Pa\u00edses visitados\n      <\/div>\n      <div class=\"gl-legend-item\">\n        <div class=\"gl-legend-dot\" style=\"background:#d6d6d6;border:1px solid #bbb;\"><\/div>\n        Outros pa\u00edses\n      <\/div>\n    <\/div>\n    <button id=\"gl-nav-btn\" class=\"gl-cv-btn\">\n      <div class=\"gl-cv-btn-dot\"><\/div>\n      <span id=\"gl-nav-label\">Ver mapa mundial<\/span>\n    <\/button>\n    <button id=\"gl-cv-btn\" class=\"gl-cv-btn\">\n      <div class=\"gl-cv-btn-dot\"><\/div>\n      <span id=\"gl-cv-label\">Ver Cabo Verde no mapa<\/span>\n    <\/button>\n  <\/div>\n<\/div>\n\n<script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/leaflet\/1.9.4\/leaflet.min.js\"><\/script>\n<script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/topojson\/3.0.2\/topojson.min.js\"><\/script>\n<script>\n(function () {\n\n  var emMapaMundo = false;\n  var emCaboVerde = false;\n  var isMobile = window.innerWidth <= 600;\n\n  var defaultCenter = [52, 11];\n  var defaultZoom   = isMobile ? 2.8 : 4;\n  var worldCenter   = [20, 70];\n  var worldZoom     = isMobile ? 1 : 2;\n\n  var visited = {\n    620: \"Portugal\",\n    724: \"Espanha\",\n    250: \"Franca\",\n    372: \"Irlanda\",\n    246: \"Finlandia\",\n    528: \"Paises Baixos\",\n    100: \"Bulgaria\",\n    498: \"Moldavia\",\n    804: \"Ucrania\",\n    380: \"Italia\",\n     40: \"Austria\",\n    300: \"Grecia\",\n     56: \"Belgica (Bruxelas)\",\n    191: \"Croacia\",\n    499: \"Montenegro\",\n    233: \"Estonia\",\n    132: \"Cabo Verde\",\n    348: \"Hungria\",\n    440: \"Lituania\",\n    826: \"Reino Unido\",\n    276: \"Alemanha\",\n    566: \"Nigeria\",\n    586: \"Paquistao\",\n     36: \"Australia\",\n    554: \"Nova Zelandia\"\n  };\n\n  var cities = [\n    { name: \"Agueda\",      lat: 40.5743, lon: -8.4465, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/AguedaGF.png\" },\n    { name: \"Guimaraes\",   lat: 41.4425, lon: -8.2918, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/GuimaraesGF.jpg\" },\n    { name: \"Mafra\",       lat: 38.9358, lon: -9.3317, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/MafraGF.jpg\" },\n    { name: \"Viladecans\",  lat: 41.3167, lon:  2.0167, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/ViladecansGF.jpg\" },\n    { name: \"Silla\",       lat: 39.3639, lon: -0.4139, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/SillaGF.jpg\" },\n    { name: \"Galway\",      lat: 53.2707, lon: -9.0568, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/GalwayGF.jpg\" },\n    { name: \"Vaasa\",       lat: 63.0960, lon: 21.6158, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/VaasaGF.jpg\" },\n    { name: \"Assen\",       lat: 52.9925, lon:  6.5642, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/AssenGF-scaled.webp\" },\n    { name: \"Varna\",       lat: 43.2141, lon: 27.9147, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/VarnaGF.jpg\" },\n    { name: \"Edinet\",      lat: 48.1686, lon: 27.3050, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/EdinetGF.jpg\" },\n    { name: \"Ternopil\",    lat: 49.5535, lon: 25.5948, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/TernopilGF-scaled.jpg\" },\n    { name: \"Borgomanero\", lat: 45.6975, lon:  8.4644, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/BorgomaneroGF.jpg\" },\n    { name: \"Linz\",        lat: 48.3069, lon: 14.2858, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/LinzGF.jpg\" },\n    { name: \"Ioannina\",    lat: 39.6650, lon: 20.8537, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/IoanninaGF.jpg\" },\n    { name: \"Bruxelas\",    lat: 50.8503, lon:  4.3517, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/BruxelasGF.jpg\" },\n    { name: \"Kolasin\",     lat: 42.8231, lon: 19.5231, img: \"https:\/\/greenleaf.agueda.pt\/wp-content\/uploads\/2026\/04\/KolasinGF.jpg\" }\n  ];\n\n  var map = L.map('gl-map', {\n    center: defaultCenter,\n    zoom: defaultZoom,\n    minZoom: 1,\n    maxZoom: 10,\n    zoomSnap: 0.5,\n    zoomControl: true,\n    scrollWheelZoom: true\n  });\n\n  L.tileLayer('https:\/\/{s}.basemaps.cartocdn.com\/light_nolabels\/{z}\/{x}\/{y}{r}.png', {\n    attribution: '&copy; OpenStreetMap &copy; CARTO',\n    subdomains: 'abcd',\n    maxZoom: 19\n  }).addTo(map);\n\n  function styleCountry(feature) {\n    var isVisited = visited[+feature.id];\n    return {\n      fillColor:   isVisited ? '#3B6D11' : '#d6d6d6',\n      fillOpacity: isVisited ? 0.75 : 0.45,\n      color:       '#ffffff',\n      weight:      isVisited ? 1.2 : 0.5,\n      opacity:     1\n    };\n  }\n\n  var geojsonLayer;\n\n  function onEachFeature(feature, layer) {\n    var name = visited[+feature.id];\n    if (!name) { return; }\n    layer.on({\n      mouseover: function (e) {\n        e.target.setStyle({ fillColor: '#639922', fillOpacity: 0.9, weight: 2 });\n        e.target.bindTooltip('<strong>' + name + '<\/strong>', {\n          sticky: true, direction: 'top'\n        }).openTooltip();\n      },\n      mouseout: function (e) {\n        geojsonLayer.resetStyle(e.target);\n        e.target.closeTooltip();\n      }\n    });\n  }\n\n  function isOverseas(polygon) {\n    try {\n      var lon = polygon[0][0][0];\n      var lat = polygon[0][0][1];\n      return lon < -15 || lat < 25;\n    } catch (e) {\n      return false;\n    }\n  }\n\n  function mostrarPopup(city, clientX, clientY) {\n    var popup   = document.getElementById('gl-city-popup');\n    var img     = document.getElementById('gl-city-popup-img');\n    var nameEl  = document.getElementById('gl-city-popup-name');\n    var section = document.getElementById('gl-map-section');\n    var rect    = section.getBoundingClientRect();\n\n    img.src            = city.img;\n    img.alt            = city.name;\n    nameEl.textContent = city.name;\n\n    var x = clientX - rect.left + 14;\n    var y = clientY - rect.top  - 60;\n\n    if (x + 210 > rect.width) { x = x - 230; }\n    if (y < 0) { y = 10; }\n\n    popup.style.left    = x + 'px';\n    popup.style.top     = y + 'px';\n    popup.style.display = 'block';\n  }\n\n  fetch('https:\/\/cdn.jsdelivr.net\/npm\/world-atlas@2\/countries-50m.json')\n    .then(function (r) { return r.json(); })\n    .then(function (world) {\n      var geojson = topojson.feature(world, world.objects.countries);\n\n      geojson.features.forEach(function (feature) {\n        if (+feature.id !== 250) { return; }\n        if (!feature.geometry) { return; }\n        if (feature.geometry.type === 'MultiPolygon') {\n          var filtered = feature.geometry.coordinates.filter(function (poly) {\n            return !isOverseas(poly);\n          });\n          if (filtered.length > 0) {\n            feature.geometry.coordinates = filtered;\n          }\n        }\n      });\n\n      geojsonLayer = L.geoJSON(geojson, {\n        style: styleCountry,\n        onEachFeature: onEachFeature\n      }).addTo(map);\n\n      var pinIcon = L.divIcon({\n        className: 'gl-pin',\n        html: '<div class=\"gl-pin-inner\"><\/div>',\n        iconSize:   [12, 12],\n        iconAnchor: [6, 6]\n      });\n\n      cities.forEach(function (city) {\n        var marker = L.marker([city.lat, city.lon], { icon: pinIcon }).addTo(map);\n        marker.bindTooltip('<strong>' + city.name + '<\/strong>', {\n          direction: 'top',\n          offset: [0, -10]\n        });\n        marker.on('click', function (e) {\n          e.originalEvent.stopPropagation();\n          mostrarPopup(city, e.originalEvent.clientX, e.originalEvent.clientY);\n        });\n      });\n    });\n\n  document.getElementById('gl-city-popup-close').addEventListener('click', function () {\n    document.getElementById('gl-city-popup').style.display = 'none';\n  });\n\n  document.getElementById('gl-nav-btn').addEventListener('click', function () {\n    var label = document.getElementById('gl-nav-label');\n    if (!emMapaMundo) {\n      map.flyTo(worldCenter, worldZoom, { duration: 1.8 });\n      label.textContent = 'Voltar ao mapa Europa';\n      emMapaMundo = true;\n    } else {\n      map.flyTo(defaultCenter, defaultZoom, { duration: 1.8 });\n      label.textContent = 'Ver mapa mundial';\n      emMapaMundo = false;\n    }\n  });\n\n  document.getElementById('gl-cv-btn').addEventListener('click', function () {\n    var label = document.getElementById('gl-cv-label');\n    if (!emCaboVerde) {\n      map.flyTo([16.0, -24.0], 7, { duration: 1.8 });\n      label.textContent = 'Voltar ao mapa anterior';\n      emCaboVerde = true;\n    } else {\n      map.flyTo(defaultCenter, defaultZoom, { duration: 1.8 });\n      label.textContent = 'Ver Cabo Verde no mapa';\n      emCaboVerde = false;\n    }\n  });\n\n  document.addEventListener('click', function (e) {\n    var popup = document.getElementById('gl-city-popup');\n    if (popup.style.display === 'none') return;\n    if (popup.contains(e.target)) return;\n    popup.style.display = 'none';\n  });\n\n})();\n<\/script>\n\n<div style=\"text-align:center; margin-top: 14px; font-size:0.9rem; font-weight:600; color:#6c9151;\">\n  Em atualiza\u00e7\u00e3o\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Os nossos destinos Pa\u00edses onde o \u00c1gueda Green Leaf j\u00e1 esteve presente &#x2715; Pa\u00edses visitados Outros pa\u00edses Ver mapa mundial [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3546","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/greenleaf.agueda.pt\/index.php\/wp-json\/wp\/v2\/posts\/3546","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/greenleaf.agueda.pt\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/greenleaf.agueda.pt\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/greenleaf.agueda.pt\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/greenleaf.agueda.pt\/index.php\/wp-json\/wp\/v2\/comments?post=3546"}],"version-history":[{"count":79,"href":"https:\/\/greenleaf.agueda.pt\/index.php\/wp-json\/wp\/v2\/posts\/3546\/revisions"}],"predecessor-version":[{"id":3882,"href":"https:\/\/greenleaf.agueda.pt\/index.php\/wp-json\/wp\/v2\/posts\/3546\/revisions\/3882"}],"wp:attachment":[{"href":"https:\/\/greenleaf.agueda.pt\/index.php\/wp-json\/wp\/v2\/media?parent=3546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/greenleaf.agueda.pt\/index.php\/wp-json\/wp\/v2\/categories?post=3546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/greenleaf.agueda.pt\/index.php\/wp-json\/wp\/v2\/tags?post=3546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}