Demos - Room
Design
Define the Area and Label. Add a stroke to the Label.
HTML
<div id="mapnj-room">
<svg>...</svg>
</div>
JavaScript
Specify the area that is selected on page load. Specify a callback for the event when the area is switched.
const mapnjRoom = new MapNJ("#mapnj-room", {
activeAreaId: "room",
});
mapnjRoom.on("AREA_CHANGE", (mapnj) => {
if (mapnj.state.activeAreaId === "secret") {
alert("ふふふ、この部屋に気づきましたか...");
}
});