<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jsvectormap@1.7.0/dist/jsvectormap.min.css">
<script src="https://cdn.jsdelivr.net/npm/jsvectormap@1.7.0/dist/jsvectormap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jsvectormap@1.7.0/dist/maps/world-merc.js"></script>
<div id="alacartaMapWrap">
<div id="alacartaMap"></div>
</div>
<style>
#alacartaMapWrap{
width:80%;
height:520px;
margin:0 auto;
border:2px solid #F68B1E;
border-radius:20px;
overflow:hidden;
background:#fff;
}
#alacartaMap{ width:100%; height:100%; }
.jvm-tooltip{
z-index:2147483647 !important;
background:#fff !important;
color:#0f3b35 !important;
border-radius:12px !important;
padding:10px 12px !important;
font-size:12px !important;
font-weight:800 !important;
box-shadow:0 14px 34px rgba(0,0,0,.14) !important;
pointer-events:none !important;
border: 1px solid rgba(246,139,30,.22) !important;
}
#alacartaMap .jvm-marker{ cursor:pointer; }
#alacartaMap text.jvm-marker-label{
font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
font-size: 16px;
font-weight: 700;
fill: #2b2f36;
paint-order: stroke fill;
stroke: rgba(255,255,255,.90);
stroke-width: 4px;
stroke-linejoin: round;
pointer-events: none;
user-select: none;
}
</style>
<script>
(() => {
const COUNTRIES = {
PE:{ name:"PÉROU", url:"/destination/perou", coords:[-9.19,-75.02]},
EC:{ name:"ÉQUATEUR", url:"/destination/equateur", coords:[-1.83,-78.18]},
CO:{ name:"COLOMBIE", url:"/destination/colombie", coords:[4.57,-74.30]},
CL:{ name:"CHILI", url:"/destination/chili", coords:[-35.68,-71.54]},
BR:{ name:"BRÉSIL", url:"/destination/bresil", coords:[-14.23,-51.93]},
BO:{ name:"BOLIVIE", url:"/destination/bolivie", coords:[-16.29,-63.59]},
AR:{ name:"ARGENTINE", url:"/destination/argentine", coords:[-38.42,-63.62]},
PA:{ name:"PANAMA", url:"/destination/panama", coords:[8.54,-80.78]},
MX:{ name:"MEXIQUE", url:"/destination/mexique", coords:[23.63,-102.55]},
GT:{ name:"GUATEMALA", url:"/destination/guatemala", coords:[15.78,-90.23]},
CR:{ name:"COSTA RICA", url:"/destination/costa-rica", coords:[9.75,-83.75]},
DO:{ name:"RÉPUBLIQUE DOMINICAINE", url:"/destination/republique-dominicaine", coords:[18.74,-70.16]},
PR:{ name:"PORTO RICO", url:"/destination/porto-rico", coords:[18.22,-66.59]},
CU:{ name:"CUBA", url:"/destination/cuba", coords:[21.52,-77.78]}
};
const ACTIVE = Object.keys(COUNTRIES);
// ✅ TA PALETTE EXACTE (par code ISO)
const COUNTRY_COLORS = {
BR:"#F8C07A", // Brésil = orange pâle
AR:"#F4A7C3", // Argentine = rose
CL:"#BFE7C0", // Chili = vert pâle
BO:"#D9D9D9", // Bolivie = gris pâle
PE:"#D8C6F2", // Pérou = violet pâle
EC:"#F4B0A8", // Equateur = rouge pâle
CO:"#0B3D91", // Colombie = bleu foncé
PA:"#9AA3AF", // Panama = gris
CR:"#F4B0A8", // Costa Rica = rouge pâle
GT:"#1E7A4B", // Guatemala = vert foncé
MX:"#F6E7A5", // Mexique = jaune pâle
CU:"#9DD7F5", // Cuba = bleu clair
DO:"#FFD200", // Rép Dom = jaune brillant
PR:"#8B1E2D" // Porto Rico = rouge foncé
};
const ORANGE = "#F68B1E";
const WORLD_GRAY = "#D6DBE0";
const hexToRgb = (h) => {
h = h.replace("#","").trim();
if (h.length === 3) h = h.split("").map(c=>c+c).join("");
const n = parseInt(h,16);
return { r:(n>>16)&255, g:(n>>8)&255, b:n&255 };
};
const rgbToHex = ({r,g,b}) =>
"#" + [r,g,b].map(v => v.toString(16).padStart(2,"0")).join("");
const lighten = (hex, amt=0.22) => {
const {r,g,b} = hexToRgb(hex);
return rgbToHex({
r: Math.round(r + (255-r)*amt),
g: Math.round(g + (255-g)*amt),
b: Math.round(b + (255-b)*amt)
});
};
function focusToHome(map){
if (typeof map.setFocus === "function") map.setFocus({ regions: ACTIVE, animate:true });
else map.reset();
}
function waitForMapReady(tries=120){
if (window.jsVectorMap) return init();
if (tries <= 0) return console.error("jsVectorMap / world_merc pas chargé. Vérifie le Footer Webflow (Before </body>)");
setTimeout(() => waitForMapReady(tries-1), 50);
}
function init(){
const MARKERS = ACTIVE.map(code => ({
name: COUNTRIES[code].name,
coords: COUNTRIES[code].coords,
code
}));
const map = new jsVectorMap({
selector:"#alacartaMap",
map:"world_merc",
backgroundColor:"transparent",
zoomButtons:false,
zoomOnScroll:true,
zoomOnScrollSpeed:0.22,
zoomMin:1,
zoomMax:7,
zoomAnimate:true,
draggable:true,
focusOn:{ regions: ACTIVE, animate:true },
regionStyle:{
initial:{ fill: WORLD_GRAY, stroke:"#fff", strokeWidth:0.0 },
hover:{ stroke: ORANGE, strokeWidth:1.1 },
// ✅ IMPORTANT : on neutralise “selected” pour ne pas écraser la palette
selected:{ fill: null },
selectedHover:{ fill: null }
},
// ✅ Couleur par pays (c’est ça qui doit gagner)
series:{
regions:[{ attribute:"fill", values: COUNTRY_COLORS }]
},
// ❌ on retire selectedRegions (ça cassait tes couleurs)
// selectedRegions: ACTIVE,
labels: { markers: { render: (marker) => marker.name } },
markers: MARKERS,
markerStyle:{
initial:{ r:9, fill:"#2b2f36", stroke:"rgba(255,255,255,.90)", strokeWidth:6 },
hover:{ fill:"#2b2f36", stroke:"rgba(246,139,30,.90)", strokeWidth:7 }
},
onRegionTooltipShow(e, tooltip, code){
if(!COUNTRIES[code]){ e.preventDefault(); return; }
tooltip.text(COUNTRIES[code].name);
},
onRegionClick(e, code){
if(COUNTRIES[code]?.url) window.location.href = COUNTRIES[code].url;
},
onMarkerTooltipShow(e, tooltip, index){
const m = MARKERS[index];
if (m) tooltip.text(m.name);
},
onMarkerClick(e, index){
const m = MARKERS[index];
if (m?.code && COUNTRIES[m.code]?.url) window.location.href = COUNTRIES[m.code].url;
},
onRegionOver(e, code){
if(!COUNTRIES[code]) return;
const base = COUNTRY_COLORS[code] || WORLD_GRAY;
const el = map.regions[code]?.element;
if (el) el.setStyle({ fill: lighten(base, 0.22), filter:"drop-shadow(0 10px 14px rgba(0,0,0,.10))" });
},
onRegionOut(e, code){
if(!COUNTRIES[code]) return;
const base = COUNTRY_COLORS[code] || WORLD_GRAY;
const el = map.regions[code]?.element;
if (el) el.setStyle({ fill: base, filter:"none" });
},
onLoaded(m){
document.querySelectorAll("#alacartaMap [data-code]").forEach(el=>{
const code = el.getAttribute("data-code");
el.style.cursor = COUNTRIES[code] ? "pointer" : "default";
if (!COUNTRIES[code]) el.style.opacity = "0.70";
});
document.querySelectorAll('#alacartaMap text').forEach(t=>{
if (t.textContent && t.textContent.length) t.classList.add('jvm-marker-label');
});
setTimeout(() => focusToHome(m), 140);
window.addEventListener("resize", () => m.updateSize());
}
});
const mapEl = document.getElementById("alacartaMap");
let resetTimer = null;
mapEl.addEventListener("mouseleave", () => {
resetTimer = setTimeout(() => focusToHome(map), 550);
});
mapEl.addEventListener("mouseenter", () => {
if (resetTimer) clearTimeout(resetTimer);
});
}
waitForMapReady();
})();
</script>