Querying indoor map floor outline information
Obtain the outline for an indoor map floor. Note: Floor outlines are only available for indoor maps submitted from 12 Aug, 2019 onwards. Please resubmit your indoor map if floor outlines information is empty for your interior.
<!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" />
</head>
<body>
<div style="position: relative">
<div id="map" style="height: 400px"></div>
<script>
var map = Wrld.map("map", "your_api_key_here", {
center: [56.459801, -2.977928],
zoom: 18,
indoorsEnabled: true
});
function onInitialStreamingComplete() {
map.indoors.enter("westport_house");
Wrld.indoorMapFloorOutlines
.indoorMapFloorOutlineInformation("westport_house", 2)
.addTo(map);
}
function onIndoormapFloorOutlineInformationLoaded(event) {
var outlineInformation = event.indoorMapFloorOutlineInformation;
var polygons = outlineInformation.getIndoorMapFloorOutlinePolygons();
polygons.forEach(function(polygon) {
var polygonOptions = {indoorMapId: outlineInformation.getIndoorMapId(),
indoorMapFloorId: outlineInformation.getIndoorMapFloorId()};
var polyPoints = [];
polyPoints.push(polygon.getOuterRing().getLatLngPoints());
polygon.getInnerRings().forEach(function(innerRing){
polyPoints.push(innerRing.getLatLngPoints());
});
Wrld.polygon(polyPoints, polygonOptions).addTo(map);
});
}
function onIndoorMapEntered() {
map.indoors.setFloor(2);
map.setView([56.459984, -2.978238], 19);
}
map.on("initialstreamingcomplete", onInitialStreamingComplete);
map.indoors.on("indoormapenter", onIndoorMapEntered);
map.indoorMapFloorOutlines.on("indoormapflooroutlineinformationloaded", onIndoormapFloorOutlineInformationLoaded);
</script>
</div>
</body>
</html>