I have added a hover state to the countries in my map, but the hover state only works in the Studio environment and not in any other external embed e.g. iframe or preview.
I have created a codepen to demonstrate the issue: https://codepen.io/jplatford/pen/emOrebx.
Mapbox provides the following snippet. I can see that it hits the handler because of the console log, but the state (name hover-state) never seems to take affect and change the colour of the country currently hovered over.
map.addInteraction("move-handler", {
type: "mousemove",
target: {
"layerId": "available-countries"
},
handler: (e) => {
if (e.feature) {
if (feature) {
map.setFeatureState(feature, { ["hover-state"]: false });
}
feature = e.feature;
console.log(feature);
map.setFeatureState(feature, { ["hover-state"]: true });
}
if (feature) {
map.setFeatureState(feature, { ["hover-state"]: false });
feature = null;
}
}
});