diff --git a/src/Map.js b/src/Map.js
index fbc93b6..084f0ea 100644
--- a/src/Map.js
+++ b/src/Map.js
@@ -140,7 +140,17 @@ function min_max(request)
return [minX, maxX, minY, maxY];
}
-function newPolygon(element, positions, selectedRoom, callback)
+function floorList(connectedFloors, callbackChangeFloor)
+{
+ let htmlFloorList = [];
+ for (const floor in connectedFloors)
+ {
+ htmlFloorList = [...htmlFloorList,
{callbackChangeFloor(floor["id"]);}}> {floor["name"]} ];
+ }
+ return htmlFloorList;
+}
+
+function newPolygon(element, positions, selectedRoom, callbackRoomSelected, callbackChangeFloor)
{
// Auxiliary function to return the appropriate polygon depending
// on wether it is a room, a lift, a staircase or toilets
@@ -148,7 +158,7 @@ function newPolygon(element, positions, selectedRoom, callback)
if (element["type"] === "S")
{
// In this case, the room is a staircase so we add a Stairs component
- return
callback(element["id"])}}>
+ return callbackRoomSelected(element["id"])}}>
{element["id"]}
{ console.log("escalier"); }}>
@@ -165,7 +175,7 @@ function newPolygon(element, positions, selectedRoom, callback)
else if (element["type"] === "L")
{
// In this case the room is a lift so we add a Lift component
- return callback(element["id"])}}>
+ return callbackRoomSelected(element["id"])}}>
{element["id"]}
{ console.log("ascenseur"); }}>
@@ -181,7 +191,7 @@ function newPolygon(element, positions, selectedRoom, callback)
}
else if (element["type"] === "T")
{
- return callback(element["id"])}}>
+ return callbackRoomSelected(element["id"])}}>
{element["id"]}
{ console.log("toilettes"); }}>
@@ -198,13 +208,13 @@ function newPolygon(element, positions, selectedRoom, callback)
else if (element["type"] === "R")
{
// In this case it is a regular room
- return callback(element["id"])}}>
+ return callbackRoomSelected(element["id"])}}>
{element["id"]}
}
}
-function list_polygons(request, center, callback, selectedRoom)
+function list_polygons(request, center, callbackRoomSelected, selectedRoom, callbackChangeFloor)
{
// Main function to calculate the list of polygons (React components)
// Taking the request as parameter, the center of the points of the request
@@ -221,13 +231,13 @@ function list_polygons(request, center, callback, selectedRoom)
// the "Polygon" react-leaflet component
return [-(pt["y"] - center[1]) / 25, (pt["x"] - center[0]) / 25];
});
- const pol = newPolygon(element, positions, selectedRoom, callback);
+ const pol = newPolygon(element, positions, selectedRoom, callbackRoomSelected, callbackChangeFloor);
polygons = [...polygons, pol];
}
return polygons;
}
-function buildPols(request, callback, selectedRoom)
+function buildPols(request, callbackRoomSelected, selectedRoom, callbackChangeFloor)
{
// This function just calls the list_polygons one with appropriate parameters (precalculate center)
const minMaxXY = min_max(request);
@@ -236,11 +246,11 @@ function buildPols(request, callback, selectedRoom)
const minY = minMaxXY[2];
const maxY = minMaxXY[3];
const center = [(maxX + minX) / 2, (maxY + minY) / 2];
- const polygons = list_polygons(request, center, callback, selectedRoom);
+ const polygons = list_polygons(request, center, callbackRoomSelected, selectedRoom, callbackChangeFloor);
return polygons;
}
-function Map({callbackRoomSelected, selectedRoom, floorID})
+function Map({callbackRoomSelected, selectedRoom, floorID, callbackChangeFloor})
{
// When the user selects a room on the map, call callbackRoomSelected.
// The room that is currently selected is selectedRoom. It is null if no room
@@ -264,7 +274,7 @@ function Map({callbackRoomSelected, selectedRoom, floorID})
}, [request, callbackRoomSelected, selectedRoom]);
const polygons = createPolygons(request, callbackRoomSelected, selectedRoom);
*/
- const polygons = buildPols(request, callbackRoomSelected, selectedRoom);
+ const polygons = buildPols(request, callbackRoomSelected, selectedRoom, callbackChangeFloor);
return
{polygons}