architwin 1.12.1 → 1.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/minimap.js CHANGED
@@ -30,6 +30,7 @@ let _mapImg = null;
30
30
  let _mapWidth;
31
31
  let isMinimapNavigation = false;
32
32
  let _minimapSweepCollection = {};
33
+ let _customMapSweepCollection = {};
33
34
  let _minimapSweepMarkerElements = [];
34
35
  let _currentFloor;
35
36
  let _mapImgEl;
@@ -44,6 +45,7 @@ let minX = 0, minY = 0, maxX = 0, maxY = 0;
44
45
  let _customMapContainer;
45
46
  let _customMapFloorData = [];
46
47
  let _minimapPosition = "bottomRight";
48
+ let _mpSdk;
47
49
  let notyf = new Notyf({ position: { x: 'left', y: 'bottom' }, duration: 4500, types: [
48
50
  {
49
51
  type: 'info',
@@ -139,9 +141,9 @@ function setMap(mpSdk, appKey, mapId, openOnLoad) {
139
141
  _mapBox = _mapContainer.parentNode;
140
142
  window.addEventListener('resize', handleMapResize);
141
143
  // Setup minimap position dropdown
142
- const dropDownElement = yield createDropdown(mapPositions);
144
+ const dropDownElement = yield createDropdown();
143
145
  _mapBox.insertBefore(dropDownElement, _mapBox.firstChild);
144
- mapPositionHandler(mapPositions);
146
+ mapPositionHandler();
145
147
  // Apply custom values from mapConfig
146
148
  if (_mpConfig.mapConfig) {
147
149
  if (_mpConfig.mapConfig.position && mapPositions.includes(_mpConfig.mapConfig.position)) {
@@ -281,7 +283,7 @@ function setMap(mpSdk, appKey, mapId, openOnLoad) {
281
283
  }
282
284
  },
283
285
  onCollectionUpdated: function (collection) {
284
- log.info('JOCHE default the entire up-to-date collection', collection);
286
+ log.info('default the entire up-to-date collection', collection);
285
287
  _minimapSweepCollection = collection;
286
288
  if (_currentFloor) {
287
289
  toggleSweepMarkerFloors(_currentFloor);
@@ -908,7 +910,7 @@ function setStandaloneMap(modelId, appKey, mapId) {
908
910
  * @param mapPositions An array of strings representing the minimap positions (e.g., 'topLeft','bottomRight').
909
911
  * @returns HTLMElement with the specified position options.
910
912
  */
911
- function createDropdown(mapPositions) {
913
+ function createDropdown() {
912
914
  return __awaiter(this, void 0, void 0, function* () {
913
915
  log.info('createDropdown');
914
916
  const element = document.createElement('div');
@@ -938,52 +940,62 @@ function createDropdown(mapPositions) {
938
940
  return element;
939
941
  });
940
942
  }
941
- function mapPositionHandler(mapPositions) {
943
+ function mapPositionHandler() {
944
+ log.info("mapPositionHandler()");
942
945
  const dropdown = document.getElementById('at-map-position-dropdown');
943
- const mapTopRight = document.getElementById('at_map_top_right');
944
- const mapTopLeft = document.getElementById('at_map_top_left');
945
- const mapBottomRight = document.getElementById('at_map_bottom_right');
946
- const mapBottomLeft = document.getElementById('at_map_bottom_left');
947
946
  const options = document.getElementById('at-map-position-options');
947
+ if (!dropdown || !options)
948
+ return;
948
949
  dropdown.addEventListener('click', () => {
949
950
  console.log("__@ Dropdown Clicked!");
950
951
  options.classList.toggle('open');
951
952
  });
952
- mapTopRight.addEventListener('click', () => {
953
- console.log("__@ Map Position: Top Right!");
954
- mapPositions.forEach(position => _mapBox.classList.remove(position));
955
- _minimapPosition = 'topRight';
956
- setMinimapPosition(_mapBox, 'topRight');
957
- if (options.classList.contains('open')) {
958
- options.classList.remove('open');
959
- }
960
- });
961
- mapTopLeft.addEventListener('click', () => {
962
- console.log("__@ Map Position: Top Left!");
963
- mapPositions.forEach(position => _mapBox.classList.remove(position));
964
- _minimapPosition = 'topLeft';
965
- setMinimapPosition(_mapBox, 'topLeft');
966
- if (options.classList.contains('open')) {
953
+ const positionMap = {
954
+ 'at_map_top_right': 'topRight',
955
+ 'at_map_top_left': 'topLeft',
956
+ 'at_map_bottom_right': 'bottomRight',
957
+ 'at_map_bottom_left': 'bottomLeft'
958
+ };
959
+ Object.entries(positionMap).forEach(([elementId, position]) => {
960
+ const element = document.getElementById(elementId);
961
+ if (!element)
962
+ return;
963
+ element.addEventListener('click', () => {
964
+ console.log(`__@ Map Position: ${position}!`);
965
+ mapPositions.forEach(pos => _mapBox.classList.remove(pos));
966
+ _minimapPosition = position;
967
+ setMinimapPosition(_mapBox, position);
967
968
  options.classList.remove('open');
968
- }
969
+ });
969
970
  });
970
- mapBottomLeft.addEventListener('click', () => {
971
- console.log("__@ Map Position: Bottom Left!");
972
- mapPositions.forEach(position => _mapBox.classList.remove(position));
973
- _minimapPosition = 'bottomLeft';
974
- setMinimapPosition(_mapBox, 'bottomLeft');
975
- if (options.classList.contains('open')) {
976
- options.classList.remove('open');
977
- }
971
+ }
972
+ function customMapPositionHandler(mapContainer) {
973
+ log.info("customMapPositionHandler()");
974
+ const dropdown = document.getElementById('at-cmap-position-dropdown');
975
+ const options = document.getElementById('at-cmap-position-options');
976
+ if (!dropdown || !options)
977
+ return;
978
+ dropdown.addEventListener('click', () => {
979
+ console.log("__@ [CMap] Position Dropdown Clicked!");
980
+ options.classList.toggle('open');
978
981
  });
979
- mapBottomRight.addEventListener('click', () => {
980
- console.log("__@ Map Position: Bottom Right!");
981
- mapPositions.forEach(position => _mapBox.classList.remove(position));
982
- _minimapPosition = 'bottomRight';
983
- setMinimapPosition(_mapBox, 'bottomRight');
984
- if (options.classList.contains('open')) {
982
+ const positionMap = {
983
+ 'at-cmap-top-right': 'topRight',
984
+ 'at-cmap-top-left': 'topLeft',
985
+ 'at-cmap-bottom-right': 'bottomRight',
986
+ 'at-cmap-bottom-left': 'bottomLeft',
987
+ };
988
+ Object.entries(positionMap).forEach(([elementId, position]) => {
989
+ const element = document.getElementById(elementId);
990
+ if (!element)
991
+ return;
992
+ element.addEventListener('click', () => {
993
+ console.log(`__@ [CMap] Map Position: ${position}!`);
994
+ mapPositions.forEach(pos => mapContainer.classList.remove(pos));
995
+ _minimapPosition = position;
996
+ setMinimapPosition(mapContainer, position);
985
997
  options.classList.remove('open');
986
- }
998
+ });
987
999
  });
988
1000
  }
989
1001
  /**
@@ -1044,10 +1056,14 @@ function handleMapResize() {
1044
1056
  * @returns {HTMLDivElement} The custom minimap element.
1045
1057
  */
1046
1058
  function setupCustomMinimapPane() {
1047
- log.info('setupCustomMinimap');
1048
- log.info("_minimapPosition: ", _minimapPosition);
1049
- return `
1059
+ return __awaiter(this, void 0, void 0, function* () {
1060
+ log.info('setupCustomMinimap');
1061
+ log.info("_minimapPosition: ", _minimapPosition);
1062
+ return `
1050
1063
  <div id="at-custom-minimap-pane" class="at_overlay_left_minimap ${_minimapPosition}" style="display:none">
1064
+ <div>
1065
+ ${setMapPositionDropdown()}
1066
+ </div>
1051
1067
  <div id="at-custom-map-close-btn" class="at_close_minimap">
1052
1068
  <span class="mdi mdi-window-close" id="at-close-minimap-btn" data-cy="at-close-minimap-btn"></span>
1053
1069
  </div>
@@ -1065,6 +1081,31 @@ function setupCustomMinimapPane() {
1065
1081
  </div>
1066
1082
 
1067
1083
  `;
1084
+ });
1085
+ }
1086
+ function setMapPositionDropdown() {
1087
+ return `
1088
+ <div id="at-cmap-position-dropdown" class="at_map_positions">
1089
+ <span class="mdi mdi-overscan" style="color: white; cursor: pointer;"></span>
1090
+ </div>
1091
+
1092
+ <div style="position:absolute;">
1093
+ <div class="at_dropdown_options" style="z-index: 999 !important; width: 150px !important;" id="at-cmap-position-options" data-cy="at-cmap-position-options">
1094
+ <div id="at-cmap-bottom-right" class="at_dropdown at_flex at_items_center at_option at_custom_dropdown_option">
1095
+ <span class="mdi mdi-pan-bottom-right">${i18n.t('BottomRight')}</span>
1096
+ </div>
1097
+ <div id="at-cmap-top-left" class="at_dropdown at_flex at_items_center at_option at_custom_dropdown_option">
1098
+ <span class="mdi mdi-pan-top-left">${i18n.t('UpperLeft')}</span>
1099
+ </div>
1100
+ <div id="at-cmap-bottom-left" class="at_dropdown at_flex at_items_center at_option at_custom_dropdown_option">
1101
+ <span class="mdi mdi-pan-bottom-left">${i18n.t('BottomLeft')}</span>
1102
+ </div>
1103
+ <div id="at-cmap-top-right" class="at_dropdown at_flex at_items_center at_option at_custom_dropdown_option">
1104
+ <span class="mdi mdi-pan-top-right">${i18n.t('UpperRight')}</span>
1105
+ </div>
1106
+ </div>
1107
+ </div>
1108
+ `;
1068
1109
  }
1069
1110
  /**
1070
1111
  * Sets up and returns the HTML for the custom minimap settings panel.
@@ -1131,13 +1172,21 @@ function setupCustomMinimapSettingUI() {
1131
1172
  * @param mpSdk - The Matterport SDK instance
1132
1173
  */
1133
1174
  function setCustomMap(mpSdk) {
1134
- const minimapElement = setupCustomMinimapPane();
1135
- const showcase = document.getElementById('showcase-container');
1136
- const mapContainer = document.createElement('div');
1137
- mapContainer.innerHTML = minimapElement;
1138
- showcase.append(mapContainer);
1139
- console.log("Successfully rendered.");
1140
- subscribeToFloorChanges(mpSdk);
1175
+ return __awaiter(this, void 0, void 0, function* () {
1176
+ const minimapElement = yield setupCustomMinimapPane();
1177
+ const showcase = document.getElementById('showcase-container');
1178
+ const mapContainer = document.createElement('div');
1179
+ mapContainer.innerHTML = minimapElement;
1180
+ // Inject to DOM
1181
+ showcase.append(mapContainer);
1182
+ const customMapPane = document.getElementById('at-custom-minimap-pane');
1183
+ setTimeout(() => {
1184
+ customMapPositionHandler(customMapPane);
1185
+ }, 0);
1186
+ // Subscriber floor changes
1187
+ subscribeToFloorChanges(mpSdk);
1188
+ console.log("Successfully rendered.");
1189
+ });
1141
1190
  }
1142
1191
  /**
1143
1192
  * Sets the current rotation value of the custom minimap.
@@ -1190,10 +1239,51 @@ function generateCustomMinimap(mpSdk) {
1190
1239
  // Get current floor data
1191
1240
  const currentFloor = getCurrentFloor();
1192
1241
  minX = maxX = minY = maxY = 0;
1242
+ //If there are sweep marker configurations set, apply them
1243
+ if (_mpConfig.mapConfig && _mpConfig.mapConfig.sweepMarker) {
1244
+ log.info("Apply map sweep marker config");
1245
+ // if (_mpConfig.mapConfig.sweepMarker.showOnHover == false) {
1246
+ // log.info("You are enabling to show sweep markers by default. You should probably increase the fixedSize to avoid the sweep markers overcrowding the map")
1247
+ // document.documentElement.style.setProperty("--map-sweep-display",`inline-block`)
1248
+ // }
1249
+ // if (_mpConfig.mapConfig.sweepMarker.backgroundColor) {
1250
+ // if (isValidCSSColor(_mpConfig.mapConfig.sweepMarker.backgroundColor)) {
1251
+ // document.documentElement.style.setProperty("--map-sweep-color",`${_mpConfig.mapConfig.sweepMarker.backgroundColor}`)
1252
+ // }else{
1253
+ // log.error("Invalid custom color value for sweep marker backgroundColor")
1254
+ // }
1255
+ // }
1256
+ // if (_mpConfig.mapConfig.sweepMarker.activeColor) {
1257
+ // if (isValidCSSColor(_mpConfig.mapConfig.sweepMarker.activeColor)) {
1258
+ // document.documentElement.style.setProperty("--map-sweep-active-color",`${_mpConfig.mapConfig.sweepMarker.activeColor}`)
1259
+ // }else{
1260
+ // log.error("Invalid custom color value for sweep marker activeColor")
1261
+ // }
1262
+ // }
1263
+ // if (_mpConfig.mapConfig.sweepMarker.hoverColor) {
1264
+ // if (isValidCSSColor(_mpConfig.mapConfig.sweepMarker.hoverColor)) {
1265
+ // document.documentElement.style.setProperty("--map-sweep-hover-color",`${_mpConfig.mapConfig.sweepMarker.hoverColor}`)
1266
+ // }else{
1267
+ // log.error("Invalid custom color value for sweep marker hoverColor")
1268
+ // }
1269
+ // }
1270
+ if (_mpConfig.mapConfig.sweepMarker.opacity) {
1271
+ if (Number.isInteger(_mpConfig.mapConfig.sweepMarker.opacity)) {
1272
+ document.documentElement.style.setProperty("--map-sweep-opacity", `${_mpConfig.mapConfig.sweepMarker.opacity}`);
1273
+ }
1274
+ }
1275
+ }
1193
1276
  // Render Sweeps
1194
1277
  mpSdk.Sweep.data.subscribe({
1278
+ onAdded: function (index, item) {
1279
+ log.info("onAdded Sweep");
1280
+ },
1195
1281
  onCollectionUpdated: function (collection) {
1196
- log.info('the entire up-to-date collection', collection);
1282
+ log.info('custom map: the entire up-to-date collection', collection);
1283
+ _minimapSweepCollection = collection;
1284
+ if (_currentFloor) {
1285
+ toggleSweepMarkerFloors(_currentFloor);
1286
+ }
1197
1287
  // Convert object to array
1198
1288
  const sweeps = Object.values(collection);
1199
1289
  const alignedSweeps = sweeps.filter(item => item.alignmentType === 'aligned' &&
@@ -1211,7 +1301,7 @@ function generateCustomMinimap(mpSdk) {
1211
1301
  floorIndex: item.floorInfo.sequence
1212
1302
  };
1213
1303
  });
1214
- // Display sweeps to custom map
1304
+ // // Display sweeps to custom map
1215
1305
  sweepPoints.map(item => displaySweepToCustomMap(item, mpSdk));
1216
1306
  }
1217
1307
  });
@@ -1227,10 +1317,11 @@ function generateCustomMinimap(mpSdk) {
1227
1317
  * @param mpSdk - The Matterport SDK instance
1228
1318
  */
1229
1319
  function displaySweepToCustomMap(sweepItem, mpSdk) {
1230
- log.info("displaySweepToMap");
1320
+ log.info("displaySweepToMap: sweepItem ==> ", sweepItem.id);
1231
1321
  const posX = sweepItem.x;
1232
1322
  const posY = sweepItem.y;
1233
1323
  let thisSweep = document.createElement('button');
1324
+ log.info("getCurrentSweep().id ==> ", getCurrentSweep().id);
1234
1325
  const cList = getCurrentSweep().id === sweepItem.id ? 'at_custom_sweep active' : 'at_custom_sweep';
1235
1326
  const scaleX = _customMapScale;
1236
1327
  const scaleY = (_customMapScale * 21 / 9) / _customMapTranslate;
@@ -1260,6 +1351,7 @@ function displaySweepToCustomMap(sweepItem, mpSdk) {
1260
1351
  */
1261
1352
  function onSweepMoveCustomMap(event, mpSdk) {
1262
1353
  return __awaiter(this, void 0, void 0, function* () {
1354
+ log.info("onSweepMoveCustomMap(): ", event.target.value);
1263
1355
  isMinimapNavigation = true;
1264
1356
  return mpSdk.Sweep.moveTo(event.target.value, {
1265
1357
  transition: mpSdk.Sweep.Transition.FADEOUT
@@ -1268,7 +1360,11 @@ function onSweepMoveCustomMap(event, mpSdk) {
1268
1360
  return __awaiter(this, void 0, void 0, function* () {
1269
1361
  log.info(handleMessage);
1270
1362
  isMinimapNavigation = false;
1271
- showDirection();
1363
+ const mapConfig = getMapConfig();
1364
+ if (mapConfig && mapConfig.enableCustomMap) {
1365
+ showDirection();
1366
+ updateActiveSweepButton(event.target.value);
1367
+ }
1272
1368
  if (superviz.isMeetingInitialized) {
1273
1369
  yield locateAvatar();
1274
1370
  }
@@ -1282,6 +1378,21 @@ function onSweepMoveCustomMap(event, mpSdk) {
1282
1378
  });
1283
1379
  });
1284
1380
  }
1381
+ /**
1382
+ * Updates the UI to highlight the active sweep button by its ID.
1383
+ * @param sweepId - The ID of the sweep to activate.
1384
+ */
1385
+ function updateActiveSweepButton(sweepId) {
1386
+ log.info("updateActiveSweepButton(): ", sweepId);
1387
+ const buttons = _customMapContainer.querySelectorAll('button.at_custom_sweep');
1388
+ buttons.forEach(btn => {
1389
+ const button = btn;
1390
+ button.classList.remove('active');
1391
+ if (button.value === sweepId) {
1392
+ button.classList.add('active');
1393
+ }
1394
+ });
1395
+ }
1285
1396
  /**
1286
1397
  * Resets the custom map container by clearing its contents and re-adding the custom map image.
1287
1398
  */
@@ -1353,7 +1464,10 @@ function setCustomMapYOffset(yOffset) {
1353
1464
  function getCustomMapYOffset() {
1354
1465
  return _customMapYOffset;
1355
1466
  }
1356
- // GET: CURRENT MINIMAP POSITION
1467
+ // SET & GET: CURRENT MINIMAP POSITION.
1468
+ function setCurrentMinimapPosition(position) {
1469
+ _minimapPosition = position;
1470
+ }
1357
1471
  function getMinimapPosition() {
1358
1472
  return _minimapPosition;
1359
1473
  }
@@ -1477,8 +1591,14 @@ function resetCustomMapSettingValues() {
1477
1591
  if (customMapImage)
1478
1592
  customMapImage.src = 'https://i.ibb.co/043hGg9/377.png';
1479
1593
  }
1594
+ function setMpSDK(mpSdk) {
1595
+ _mpSdk = mpSdk;
1596
+ }
1597
+ function getMpSdk() {
1598
+ return _mpSdk;
1599
+ }
1480
1600
  export {
1481
1601
  // _miniMapData as minimapData,
1482
- isMinimapNavigation, mapPositions, setMap, showMinimap, hideMinimap, locateAvatar, resetSweepMarkerColors, renderOverlaySweep, showDirection, toggleMinimapVisibility, setSweepMarkerColor, setStandaloneMap, toggleMinimapFloor, getFloorsInSpace, createDropdown, setMinimapPosition,
1602
+ isMinimapNavigation, mapPositions, setMap, showMinimap, hideMinimap, locateAvatar, resetSweepMarkerColors, renderOverlaySweep, showDirection, toggleMinimapVisibility, setSweepMarkerColor, setStandaloneMap, toggleMinimapFloor, getFloorsInSpace, createDropdown, setMinimapPosition, setCurrentMinimapPosition,
1483
1603
  // custom minimap
1484
- setCustomMap, setupCustomMinimapPane, setCustomMinimapRotation, getCustomMinimapRotation, generateCustomMinimap, setCustomMapScale, setCustomMapTranslate, setCustomMapXOffset, setCustomMapYOffset, getCustomMapScale, getCustomMapTranslate, getCustomMapXOffset, getCustomMapYOffset, setMinAndMax, setCustomMapFloorData, getCustomMapFloorData, resetCustomMapSettingValues, getMinimapPosition, };
1604
+ setCustomMap, setupCustomMinimapPane, setCustomMinimapRotation, getCustomMinimapRotation, generateCustomMinimap, setCustomMapScale, setCustomMapTranslate, setCustomMapXOffset, setCustomMapYOffset, getCustomMapScale, getCustomMapTranslate, getCustomMapXOffset, getCustomMapYOffset, setMinAndMax, setCustomMapFloorData, getCustomMapFloorData, resetCustomMapSettingValues, getMinimapPosition, subscribeToFloorChanges, setMpSDK, getMpSdk };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "architwin",
3
- "version": "1.12.1",
3
+ "version": "1.12.2",
4
4
  "description": "ArchiTwin Library for Matterport",
5
5
  "main": "./lib/architwin.js",
6
6
  "types": "./lib/architwin.d.ts",
package/static/map.css CHANGED
@@ -163,12 +163,14 @@ display: inline-block;
163
163
  }
164
164
 
165
165
  .at_overlay_left_minimap.topLeft {
166
- top: calc(var(--position-top) + 0.5rem);
166
+ bottom: calc(var(--position-top) + 27rem);
167
+ /* top: calc(var(--position-top) + 0.5rem); */
167
168
  left: 0;
168
169
  }
169
170
 
170
171
  .at_overlay_left_minimap.topRight {
171
- top: calc(var(--position-top) + 0.5rem);
172
+ /* top: calc(var(--position-top) + 0.5rem); */
173
+ bottom: calc(var(--position-top) + 27rem);
172
174
  right: 0;
173
175
  }
174
176
 
@@ -243,6 +245,7 @@ display: inline-block;
243
245
 
244
246
 
245
247
  .at_overlay_left_minimap .at_close_minimap,
248
+ .at_overlay_left_minimap .at_map_positions,
246
249
  .at_overlay_left_minimap .at_setting_icon {
247
250
  width: 2em;
248
251
  height: 2em;
@@ -264,6 +267,15 @@ display: inline-block;
264
267
  top: 0;
265
268
  }
266
269
 
270
+ .at_overlay_left_minimap .at_map_positions {
271
+ top: 0;
272
+ left: 0;
273
+ right: unset;
274
+ bottom: unset;
275
+
276
+ }
277
+
278
+
267
279
  .at_custom_minimap_settings .at_custom_button_row {
268
280
  display: flex;
269
281
  justify-content: space-between;
@@ -381,6 +393,7 @@ display: inline-block;
381
393
  margin: 0;
382
394
  height: 0.5rem;
383
395
  width: 0.5rem;
396
+ opacity: var(--map-sweep-opacity);
384
397
  border: 0.20rem solid rgba(255, 255, 0, 0.79);
385
398
  border-radius: 50%;
386
399
  box-sizing: content-box;
@@ -391,6 +404,7 @@ display: inline-block;
391
404
 
392
405
  .at_custom_sweep.active {
393
406
  background-color: orangered;
407
+ opacity: var(--map-sweep-opacity);
394
408
  border: 0.23rem solid rgba(255, 255, 0, 0.79);
395
409
  }
396
410