Picking indoor map entities
Click on the ‘Go to floor’ button to navigate indoors and click on the two meetings rooms, the desks or the office area.
<!DOCTYPE HTML>
<html>
<head>
<script src="https://unpkg.com/wrld.js@1.x.x"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.1/leaflet.css" rel="stylesheet" />
<style>
#floorButtons {
position: absolute;
z-index: 20;
}
#floorButtons button {
display: block;
width: 100%;
}
</style>
</head>
<body>
<div style="position: relative">
<div id="floorButtons">
<button onclick="toFloor()">Go to floor</button>
</div>
<div id="map" style="height: 400px"></div>
<script>
var map = Wrld.map("map", "your_api_key_here", {
center: [56.459801, -2.977928],
zoom: 15,
indoorsEnabled: true
});
var entityIdsToColorIndex = {};
var colors = [
[255, 0, 0, 128],
[0, 255, 0, 128],
[0, 0, 255, 128]
];
function onIndoorEntityClicked(event) {
event.ids.forEach(highlight);
}
function toFloor() {
map.indoors.enter("westport_house");
}
function onIndoorMapEntered() {
map.indoors.setFloor(2);
map.setView([56.459984, -2.978238], 20);
}
function highlight(id) {
entityIdsToColorIndex[id] = entityIdsToColorIndex[id] === undefined ? 0 : (entityIdsToColorIndex[id] + 1) % colors.length;
map.indoors.setEntityHighlights(id, colors[entityIdsToColorIndex[id]]);
}
map.indoors.on("indoormapenter", onIndoorMapEntered);
map.indoors.on("indoorentityclick", onIndoorEntityClicked);
</script>
</div>
</body>
</html>