@twinmatrix/spatialverse-sdk-web 0.0.2 → 0.0.4

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.
Files changed (143) hide show
  1. package/lib/cjs/index.js +9 -9
  2. package/lib/cjs/index.js.map +1 -1
  3. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +213 -294
  4. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  5. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +40 -41
  6. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  7. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +170 -196
  8. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  9. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +167 -215
  10. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  11. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +28 -30
  12. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
  13. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +861 -1170
  14. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  15. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +166 -159
  16. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  17. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js +6 -6
  18. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js.map +1 -1
  19. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +6 -6
  20. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
  21. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js +3 -3
  22. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js.map +1 -1
  23. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +523 -610
  24. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  25. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +149 -154
  26. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  27. package/lib/cjs/meta-atlas-sdk/customStyles.js +2 -2
  28. package/lib/cjs/meta-atlas-sdk/customStyles.js.map +1 -1
  29. package/lib/cjs/meta-atlas-sdk/customerLayer.js +15 -29
  30. package/lib/cjs/meta-atlas-sdk/customerLayer.js.map +1 -1
  31. package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js +5 -5
  32. package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js.map +1 -1
  33. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +809 -1033
  34. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  35. package/lib/cjs/meta-atlas-sdk/utils/helpers.js +32 -49
  36. package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
  37. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +21 -34
  38. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  39. package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js +6 -6
  40. package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js.map +1 -1
  41. package/lib/cjs/meta-atlas-sdk/utils/routing-store.js +6 -6
  42. package/lib/cjs/meta-atlas-sdk/utils/routing-store.js.map +1 -1
  43. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +363 -491
  44. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  45. package/lib/cjs/react/MetaAtlasMap.js +127 -0
  46. package/lib/cjs/react/MetaAtlasMap.js.map +1 -0
  47. package/lib/cjs/react/hooks/useDrawing/index.js +17 -18
  48. package/lib/cjs/react/hooks/useDrawing/index.js.map +1 -1
  49. package/lib/cjs/react/hooks/useFocus/index.js +48 -55
  50. package/lib/cjs/react/hooks/useFocus/index.js.map +1 -1
  51. package/lib/cjs/react/hooks/useMapEvents/index.js +40 -47
  52. package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
  53. package/lib/cjs/react/hooks/useMapOverlays/index.js +20 -21
  54. package/lib/cjs/react/hooks/useMapOverlays/index.js.map +1 -1
  55. package/lib/cjs/react/hooks/useMetaAtlas/index.js +77 -95
  56. package/lib/cjs/react/hooks/useMetaAtlas/index.js.map +1 -1
  57. package/lib/cjs/react/hooks/useMetaAtlas.js +78 -96
  58. package/lib/cjs/react/hooks/useMetaAtlas.js.map +1 -1
  59. package/lib/cjs/react/hooks/useRouting/index.js +21 -20
  60. package/lib/cjs/react/hooks/useRouting/index.js.map +1 -1
  61. package/lib/cjs/react/hooks/useSearch/index.js +35 -34
  62. package/lib/cjs/react/hooks/useSearch/index.js.map +1 -1
  63. package/lib/cjs/react/hooks/useStampRally/index.js +26 -23
  64. package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
  65. package/lib/cjs/react/hooks/useStampRally/utils.js +2 -2
  66. package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
  67. package/lib/cjs/react/index.js +31 -31
  68. package/lib/cjs/react/index.js.map +1 -1
  69. package/lib/cjs/react/stores/useMapDataStore.js +47 -62
  70. package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
  71. package/lib/cjs/react/stores/useMetaAtlasStore.js +27 -40
  72. package/lib/cjs/react/stores/useMetaAtlasStore.js.map +1 -1
  73. package/lib/esm/index.js +3 -7
  74. package/lib/esm/index.js.map +1 -1
  75. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +4 -3
  76. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  77. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +14 -12
  78. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  79. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +204 -200
  80. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  81. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +6 -6
  82. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  83. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +4 -3
  84. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
  85. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +53 -42
  86. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  87. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +18 -16
  88. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  89. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +3 -3
  90. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
  91. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +73 -79
  92. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  93. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +16 -15
  94. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  95. package/lib/esm/meta-atlas-sdk/customerLayer.js +4 -1
  96. package/lib/esm/meta-atlas-sdk/customerLayer.js.map +1 -1
  97. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +148 -124
  98. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  99. package/lib/esm/meta-atlas-sdk/utils/helpers.js +4 -2
  100. package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
  101. package/lib/esm/meta-atlas-sdk/utils/local-storage.js +6 -1
  102. package/lib/esm/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  103. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +115 -109
  104. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  105. package/lib/esm/react/MetaAtlasMap.js +120 -0
  106. package/lib/esm/react/MetaAtlasMap.js.map +1 -0
  107. package/lib/esm/react/hooks/useDrawing/index.js +2 -2
  108. package/lib/esm/react/hooks/useDrawing/index.js.map +1 -1
  109. package/lib/esm/react/hooks/useFocus/index.js +4 -3
  110. package/lib/esm/react/hooks/useFocus/index.js.map +1 -1
  111. package/lib/esm/react/hooks/useMapEvents/index.js +9 -6
  112. package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
  113. package/lib/esm/react/hooks/useMapOverlays/index.js +2 -2
  114. package/lib/esm/react/hooks/useMapOverlays/index.js.map +1 -1
  115. package/lib/esm/react/hooks/useMetaAtlas/index.js +162 -60
  116. package/lib/esm/react/hooks/useMetaAtlas/index.js.map +1 -1
  117. package/lib/esm/react/hooks/useMetaAtlas.js +162 -60
  118. package/lib/esm/react/hooks/useMetaAtlas.js.map +1 -1
  119. package/lib/esm/react/hooks/useRouting/index.js +2 -2
  120. package/lib/esm/react/hooks/useRouting/index.js.map +1 -1
  121. package/lib/esm/react/hooks/useSearch/index.js +2 -2
  122. package/lib/esm/react/hooks/useSearch/index.js.map +1 -1
  123. package/lib/esm/react/hooks/useStampRally/index.js +15 -12
  124. package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
  125. package/lib/esm/react/hooks/useStampRally/utils.js +1 -1
  126. package/lib/esm/react/hooks/useStampRally/utils.js.map +1 -1
  127. package/lib/esm/react/index.js +11 -15
  128. package/lib/esm/react/index.js.map +1 -1
  129. package/lib/esm/react/stores/useMapDataStore.js +17 -21
  130. package/lib/esm/react/stores/useMapDataStore.js.map +1 -1
  131. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts +30 -0
  132. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts.map +1 -0
  133. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts +5 -0
  134. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts.map +1 -0
  135. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts +21 -0
  136. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts.map +1 -0
  137. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts +27 -0
  138. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts.map +1 -0
  139. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts +18 -0
  140. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts.map +1 -0
  141. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts +37 -0
  142. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts.map +1 -0
  143. package/package.json +10 -7
@@ -13,42 +13,31 @@ var _length = _interopRequireDefault(require("@turf/length"));
13
13
  var _area = _interopRequireDefault(require("@turf/area"));
14
14
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
15
15
  var _mapboxGlDraw = _interopRequireDefault(require("@mapbox/mapbox-gl-draw"));
16
- var _customStyles = require("./customStyles");
17
- var _draw_marker = _interopRequireDefault(require("./mapbox_draw_custom_modes/draw_marker"));
18
- var _marker_select = _interopRequireDefault(require("./mapbox_draw_custom_modes/marker_select"));
19
- var _metaAtlasSdkCore = require("./MetaAtlasCore/meta-atlas-sdk-core");
20
- var _MainMap = _interopRequireDefault(require("./3DMap/MainMap"));
16
+ var _customStyles = require("./customStyles.js");
17
+ var _draw_marker = _interopRequireDefault(require("./mapbox_draw_custom_modes/draw_marker.js"));
18
+ var _marker_select = _interopRequireDefault(require("./mapbox_draw_custom_modes/marker_select.js"));
19
+ var _metaAtlasSdkCore = require("./MetaAtlasCore/meta-atlas-sdk-core.js");
20
+ var _MainMap = _interopRequireDefault(require("./3DMap/MainMap.js"));
21
21
  var _app = require("firebase/app");
22
22
  var _analytics = require("firebase/analytics");
23
- var _routingVisualizer = require("./utils/routing-visualizer");
24
- var _customerLayer = _interopRequireDefault(require("./customerLayer"));
25
- var _customerLayerVariant = _interopRequireDefault(require("./customerLayerVariant"));
23
+ var _index = require("./utils/routing-visualizer/index.js");
24
+ var _customerLayer = _interopRequireDefault(require("./customerLayer.js"));
25
+ var _customerLayerVariant = _interopRequireDefault(require("./customerLayerVariant.js"));
26
26
  var _booleanPointInPolygon = _interopRequireDefault(require("@turf/boolean-point-in-polygon"));
27
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
28
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
29
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
30
- function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
31
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
32
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
33
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
27
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
28
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
34
29
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
35
30
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
36
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
37
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
38
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
39
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
40
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
41
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
42
31
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
43
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
44
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // const maplibregl = require('maplibre-gl');
32
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
33
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // const maplibregl = require('maplibre-gl');
45
34
  var FilterType = /*#__PURE__*/function (FilterType) {
46
35
  FilterType["Name"] = "title";
47
36
  FilterType["LocalRef"] = "localRef";
48
37
  FilterType["WhatTaxonomy"] = "dimension_what";
49
38
  return FilterType;
50
39
  }(FilterType || {});
51
- var EventSource = exports.EventSource = /*#__PURE__*/function (EventSource) {
40
+ let EventSource = exports.EventSource = /*#__PURE__*/function (EventSource) {
52
41
  EventSource["UrlLoad"] = "url_load";
53
42
  EventSource["MapClick"] = "map_click";
54
43
  EventSource["BannerClick"] = "banner_click";
@@ -60,15 +49,69 @@ var EventSource = exports.EventSource = /*#__PURE__*/function (EventSource) {
60
49
  EventSource["StampRallyClick"] = "stamp_rally_click";
61
50
  return EventSource;
62
51
  }({});
63
- var DEFAULT_MAP_STYLE = exports.DEFAULT_MAP_STYLE = 'https://api.maptiler.com/maps/01985ac8-56d2-707b-afa8-68abfe8f18be/style.json?key=12H5hrITUbJ1sDrVPqkq';
64
- var MetaAtlasSdk = exports.MetaAtlasSdk = /*#__PURE__*/function () {
65
- function MetaAtlasSdk(accessToken, secretKey) {
66
- var _this = this;
67
- var onLoad = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
68
- var onLoadFail = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (errorMessage) {};
69
- var onRoutingStatusUpdate = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function () {};
70
- var onSearchStatusUpdate = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : function () {};
71
- _classCallCheck(this, MetaAtlasSdk);
52
+ const DEFAULT_MAP_STYLE = exports.DEFAULT_MAP_STYLE = 'https://api.maptiler.com/maps/01985ac8-56d2-707b-afa8-68abfe8f18be/style.json?key=12H5hrITUbJ1sDrVPqkq';
53
+ class MetaAtlasSdk {
54
+ setupFirebase() {
55
+ const firebaseConfig = {
56
+ apiKey: "AIzaSyBDWO2wNkotbgjbkyqVrC_OEAJ3mbvlheI",
57
+ authDomain: "tmt-lenovo-tech-day-26-id.firebaseapp.com",
58
+ projectId: "tmt-lenovo-tech-day-26-id",
59
+ storageBucket: "tmt-lenovo-tech-day-26-id.firebasestorage.app",
60
+ messagingSenderId: "618619544262",
61
+ appId: "1:618619544262:web:cb7a7953a908aeed212dc7",
62
+ measurementId: "G-HN2FS1L0P4"
63
+ };
64
+ this.firebaseApp = (0, _app.initializeApp)(firebaseConfig);
65
+ this.analytics = (0, _analytics.getAnalytics)(this.firebaseApp);
66
+ console.log('analytics: ', this.analytics);
67
+ }
68
+ logAnalyticsEvent(eventName, properties) {
69
+ console.log('logAnalyticsEvent: ', eventName, properties);
70
+ if (!this.analytics) {
71
+ console.warn('Analytics is not initialized. Event not logged:', eventName);
72
+ return;
73
+ }
74
+ if (properties) (0, _analytics.logEvent)(this.analytics, eventName, properties);else (0, _analytics.logEvent)(this.analytics, eventName);
75
+ }
76
+ onLoad() {
77
+ if (this.mapLoaded === true && this.apiAuthenticationCallbackReceived === true) {
78
+ // Setup routing visualizer
79
+ this.routingVisualizer.setupRouting(this.map);
80
+
81
+ // this.map3D.init(this.map);
82
+
83
+ if (this.onLoadCallback) {
84
+ this.onLoadCallback();
85
+ }
86
+ }
87
+ }
88
+ onLoadFail(message) {
89
+ if (this.onFailCallbackSent === false) {
90
+ this.onFailCallbackSent = true;
91
+ if (this.onLoadFailCallback) {
92
+ this.onLoadFailCallback(message);
93
+ }
94
+ }
95
+ }
96
+ initMetaAtlasCore(onRoutingStatusUpdate, onSearchStatusUpdate) {
97
+ this.metaAtlasCore.init(this.empApiURL, this.accessToken, this.secretKey, data => {
98
+ this.apiAuthenticationCallbackReceived = true;
99
+ if (data.authenticated) {
100
+ // Load routing data
101
+ this.metaAtlasCore.setupRouting(onRoutingStatusUpdate);
102
+ this.metaAtlasCore.setupMapObjectSearch(onSearchStatusUpdate);
103
+ this.map3D = new _MainMap.default(this.metaAtlasCore);
104
+ this.onLoad();
105
+ } else {
106
+ this.onLoadFail('Failed to authenticate token');
107
+ }
108
+ });
109
+ }
110
+ constructor(accessToken, secretKey) {
111
+ let onLoad = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
112
+ let onLoadFail = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : errorMessage => {};
113
+ let onRoutingStatusUpdate = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : () => {};
114
+ let onSearchStatusUpdate = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : () => {};
72
115
  _defineProperty(this, "onLoadCallback", undefined);
73
116
  _defineProperty(this, "onLoadFailCallback", undefined);
74
117
  _defineProperty(this, "mapLoaded", false);
@@ -77,7 +120,7 @@ var MetaAtlasSdk = exports.MetaAtlasSdk = /*#__PURE__*/function () {
77
120
  _defineProperty(this, "defaultFocusedTaxonomy", 'where.gbtb');
78
121
  _defineProperty(this, "currentFocus", this.defaultFocusedTaxonomy);
79
122
  _defineProperty(this, "apiAuthenticationCallbackReceived", false);
80
- _defineProperty(this, "routingVisualizer", new _routingVisualizer.RoutingVisualizer(this));
123
+ _defineProperty(this, "routingVisualizer", new _index.RoutingVisualizer(this));
81
124
  // When token middleware is online that will check the tokens.
82
125
  _defineProperty(this, "tileServer", 'https://atoms-map-tiles-middleware.sandbox.spatialverse.online');
83
126
  // HOST = 'https://atoms-sdk.qa.cag.spatialverse.online/2.0.0/';
@@ -92,45 +135,36 @@ var MetaAtlasSdk = exports.MetaAtlasSdk = /*#__PURE__*/function () {
92
135
  });
93
136
  _defineProperty(this, "popups", []);
94
137
  _defineProperty(this, "markers", []);
95
- _defineProperty(this, "addCustomerLayer", function (map, jsonToPass, onLoaded) {
96
- var customerLayerUrl = jsonToPass.customerLayerUrl;
97
- var sourceLayer = jsonToPass.sourceLayer;
98
- _jquery["default"].getJSON(customerLayerUrl, function (customerLayers) {
99
- _this.CustomerLayers = customerLayers;
100
- var _iterator = _createForOfIteratorHelper(_this.CustomerLayers),
101
- _step;
102
- try {
103
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
104
- var layer = _step.value;
105
- layer["source-layer"] = sourceLayer;
106
- map.addLayer(layer);
107
- _this.map.on('click', layer.id, function (e) {
108
- //setup new clicked feature
109
- var clickedFeature = e.features[0];
110
- _this.overRideSelectionOfDrawnPointGeometry(clickedFeature);
111
- console.log('clickedFeature: ', clickedFeature);
112
- _this.logAnalyticsEvent('feature_clicked', {
113
- feature_clicked: clickedFeature.properties.title
114
- });
115
- if (clickedFeature.properties.isSearchable && clickedFeature.properties.title != 'Transit' && clickedFeature.properties.title != 'Public') {
116
- var coords = clickedFeature.geometry.type === "Polygon" ? JSON.parse(clickedFeature.properties.center) : clickedFeature.geometry.coordinates;
117
- _this.metaAtlasCore.setLastClickedFeature({
118
- mapObjectId: clickedFeature.properties.myMapObjectId,
119
- coordinates: coords,
120
- name: clickedFeature.properties.title,
121
- whatDimension: clickedFeature.properties.dimension_what,
122
- whereDimension: clickedFeature.properties.dimension_where,
123
- geometry: clickedFeature.geometry,
124
- properties: clickedFeature.properties,
125
- clickEvent: e
126
- });
127
- }
138
+ _defineProperty(this, "addCustomerLayer", (map, jsonToPass, onLoaded) => {
139
+ let customerLayerUrl = jsonToPass.customerLayerUrl;
140
+ let sourceLayer = jsonToPass.sourceLayer;
141
+ _jquery.default.getJSON(customerLayerUrl, customerLayers => {
142
+ this.CustomerLayers = customerLayers;
143
+ for (const layer of this.CustomerLayers) {
144
+ layer["source-layer"] = sourceLayer;
145
+ map.addLayer(layer);
146
+ this.map.on('click', layer.id, e => {
147
+ //setup new clicked feature
148
+ const clickedFeature = e.features[0];
149
+ this.overRideSelectionOfDrawnPointGeometry(clickedFeature);
150
+ console.log('clickedFeature: ', clickedFeature);
151
+ this.logAnalyticsEvent('feature_clicked', {
152
+ feature_clicked: clickedFeature.properties.title
128
153
  });
129
- }
130
- } catch (err) {
131
- _iterator.e(err);
132
- } finally {
133
- _iterator.f();
154
+ if (clickedFeature.properties.isSearchable && clickedFeature.properties.title != 'Transit' && clickedFeature.properties.title != 'Public') {
155
+ const coords = clickedFeature.geometry.type === "Polygon" ? JSON.parse(clickedFeature.properties.center) : clickedFeature.geometry.coordinates;
156
+ this.metaAtlasCore.setLastClickedFeature({
157
+ mapObjectId: clickedFeature.properties.myMapObjectId,
158
+ coordinates: coords,
159
+ name: clickedFeature.properties.title,
160
+ whatDimension: clickedFeature.properties.dimension_what,
161
+ whereDimension: clickedFeature.properties.dimension_where,
162
+ geometry: clickedFeature.geometry,
163
+ properties: clickedFeature.properties,
164
+ clickEvent: e
165
+ });
166
+ }
167
+ });
134
168
  }
135
169
  onLoaded();
136
170
  });
@@ -142,1054 +176,796 @@ var MetaAtlasSdk = exports.MetaAtlasSdk = /*#__PURE__*/function () {
142
176
  this.map = null;
143
177
  this.mapBoxDraw = null;
144
178
  this.maplibregl = maplibregl;
145
- this.CustomerLayers = _customerLayer["default"];
146
- this.CustomerLayersVariant = _customerLayerVariant["default"];
179
+ this.CustomerLayers = _customerLayer.default;
180
+ this.CustomerLayersVariant = _customerLayerVariant.default;
147
181
  this.roleName = "changipublic";
148
182
  this.verNum = "1";
149
183
  this.metaAtlasCore = new _metaAtlasSdkCore.MetaAtlasCore();
150
184
  this.initMetaAtlasCore(onRoutingStatusUpdate, onSearchStatusUpdate);
151
185
  this.setupFirebase();
152
186
  }
153
- return _createClass(MetaAtlasSdk, [{
154
- key: "setupFirebase",
155
- value: function setupFirebase() {
156
- var firebaseConfig = {
157
- apiKey: "AIzaSyBDWO2wNkotbgjbkyqVrC_OEAJ3mbvlheI",
158
- authDomain: "tmt-lenovo-tech-day-26-id.firebaseapp.com",
159
- projectId: "tmt-lenovo-tech-day-26-id",
160
- storageBucket: "tmt-lenovo-tech-day-26-id.firebasestorage.app",
161
- messagingSenderId: "618619544262",
162
- appId: "1:618619544262:web:cb7a7953a908aeed212dc7",
163
- measurementId: "G-HN2FS1L0P4"
164
- };
165
- this.firebaseApp = (0, _app.initializeApp)(firebaseConfig);
166
- this.analytics = (0, _analytics.getAnalytics)(this.firebaseApp);
167
- console.log('analytics: ', this.analytics);
168
- }
169
- }, {
170
- key: "logAnalyticsEvent",
171
- value: function logAnalyticsEvent(eventName, properties) {
172
- console.log('logAnalyticsEvent: ', eventName, properties);
173
- if (!this.analytics) {
174
- console.warn('Analytics is not initialized. Event not logged:', eventName);
175
- return;
176
- }
177
- if (properties) (0, _analytics.logEvent)(this.analytics, eventName, properties);else (0, _analytics.logEvent)(this.analytics, eventName);
178
- }
179
- }, {
180
- key: "onLoad",
181
- value: function onLoad() {
182
- if (this.mapLoaded === true && this.apiAuthenticationCallbackReceived === true) {
183
- // Setup routing visualizer
184
- this.routingVisualizer.setupRouting(this.map);
185
-
186
- // this.map3D.init(this.map);
187
+ setupMap(role, mapDivOrMap) {
188
+ this.roleName = role;
187
189
 
188
- if (this.onLoadCallback) {
189
- this.onLoadCallback();
190
- }
191
- }
192
- }
193
- }, {
194
- key: "onLoadFail",
195
- value: function onLoadFail(message) {
196
- if (this.onFailCallbackSent === false) {
197
- this.onFailCallbackSent = true;
198
- if (this.onLoadFailCallback) {
199
- this.onLoadFailCallback(message);
200
- }
201
- }
202
- }
203
- }, {
204
- key: "initMetaAtlasCore",
205
- value: function initMetaAtlasCore(onRoutingStatusUpdate, onSearchStatusUpdate) {
206
- var _this2 = this;
207
- this.metaAtlasCore.init(this.empApiURL, this.accessToken, this.secretKey, function (data) {
208
- _this2.apiAuthenticationCallbackReceived = true;
209
- if (data.authenticated) {
210
- // Load routing data
211
- _this2.metaAtlasCore.setupRouting(onRoutingStatusUpdate);
212
- _this2.metaAtlasCore.setupMapObjectSearch(onSearchStatusUpdate);
213
- _this2.map3D = new _MainMap["default"](_this2.metaAtlasCore);
214
- _this2.onLoad();
215
- } else {
216
- _this2.onLoadFail('Failed to authenticate token');
217
- }
190
+ // Support both vanilla (string DOM ID) and React (Map instance) modes
191
+ if (typeof mapDivOrMap === 'string') {
192
+ // Vanilla mode: create new map instance
193
+ this.map = new maplibregl.Map({
194
+ container: mapDivOrMap,
195
+ style: DEFAULT_MAP_STYLE,
196
+ center: [110.40560122701005, 1.5626614114987702],
197
+ zoom: 18,
198
+ pitch: 42,
199
+ bearing: 23.4,
200
+ antialias: true,
201
+ attributionControl: false
218
202
  });
203
+ } else {
204
+ // React mode: use provided map instance
205
+ this.map = mapDivOrMap;
219
206
  }
220
- }, {
221
- key: "setupMap",
222
- value: function setupMap(role, mapDivOrMap) {
223
- var _this3 = this;
224
- this.roleName = role;
225
207
 
226
- // Support both vanilla (string DOM ID) and React (Map instance) modes
227
- if (typeof mapDivOrMap === 'string') {
228
- // Vanilla mode: create new map instance
229
- this.map = new maplibregl.Map({
230
- container: mapDivOrMap,
231
- style: DEFAULT_MAP_STYLE,
232
- center: [110.40560122701005, 1.5626614114987702],
233
- zoom: 18,
234
- pitch: 42,
235
- bearing: 23.4,
236
- antialias: true,
237
- attributionControl: false
208
+ // Initialize map setup (common for both modes)
209
+ const setupLayers = () => {
210
+ this.map.addSource('custom', {
211
+ type: 'vector',
212
+ url: this.tileServer + '/' + this.roleName + '/' + this.verNum + '/geojson?accessToken=' + this.accessToken
213
+ });
214
+ this.logAnalyticsEvent('open_app', {
215
+ type: 'web',
216
+ token: this.accessToken
217
+ });
218
+ this.map.on('click', e => {
219
+ // Reset last clicks
220
+ this.metaAtlasCore.setLastClickedFeature({
221
+ mapObjectId: null,
222
+ coordinates: null,
223
+ name: null,
224
+ whatDimension: null,
225
+ whereDimension: null,
226
+ geometry: null,
227
+ properties: null,
228
+ clickEvent: e
238
229
  });
239
- } else {
240
- // React mode: use provided map instance
241
- this.map = mapDivOrMap;
242
- }
230
+ this.lastClickedDrawing = this.setDrawing();
231
+ });
243
232
 
244
- // Initialize map setup (common for both modes)
245
- var setupLayers = function setupLayers() {
246
- _this3.map.addSource('custom', {
247
- type: 'vector',
248
- url: _this3.tileServer + '/' + _this3.roleName + '/' + _this3.verNum + '/geojson?accessToken=' + _this3.accessToken
249
- });
250
- _this3.logAnalyticsEvent('open_app', {
251
- type: 'web',
252
- token: _this3.accessToken
253
- });
254
- _this3.map.on('click', function (e) {
255
- // Reset last clicks
256
- _this3.metaAtlasCore.setLastClickedFeature({
257
- mapObjectId: null,
258
- coordinates: null,
259
- name: null,
260
- whatDimension: null,
261
- whereDimension: null,
262
- geometry: null,
263
- properties: null,
264
- clickEvent: e
233
+ // Setup map box draw after customerLayers so that draw geomertry shows up on top
234
+ const layersToAdd = this.CustomerLayers;
235
+ for (const layer of layersToAdd) {
236
+ layer["source-layer"] = 'geojson';
237
+ this.map.addLayer(layer);
238
+ this.map.on('click', layer.id, e => {
239
+ //setup new clicked feature
240
+ var clickedFeature = e.features[0];
241
+ console.log(clickedFeature);
242
+ this.logAnalyticsEvent('feature_clicked', {
243
+ feature_clicked: clickedFeature.properties.title
265
244
  });
266
- _this3.lastClickedDrawing = _this3.setDrawing();
267
- });
268
-
269
- // Setup map box draw after customerLayers so that draw geomertry shows up on top
270
- var layersToAdd = _this3.CustomerLayers;
271
- var _iterator2 = _createForOfIteratorHelper(layersToAdd),
272
- _step2;
273
- try {
274
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
275
- var layer = _step2.value;
276
- layer["source-layer"] = 'geojson';
277
- _this3.map.addLayer(layer);
278
- _this3.map.on('click', layer.id, function (e) {
279
- //setup new clicked feature
280
- var clickedFeature = e.features[0];
281
- console.log(clickedFeature);
282
- _this3.logAnalyticsEvent('feature_clicked', {
283
- feature_clicked: clickedFeature.properties.title
284
- });
285
- _this3.overRideSelectionOfDrawnPointGeometry(clickedFeature);
286
- if (clickedFeature.properties.dimension_what.includes('what.infra.garden') || clickedFeature.properties.isSearchable && clickedFeature.properties.title != 'Transit' && clickedFeature.properties.title != 'Public') {
287
- var coords = clickedFeature.geometry.type === "Polygon" || clickedFeature.geometry.type === "MultiPolygon" ? JSON.parse(clickedFeature.properties.center) : clickedFeature.geometry.coordinates;
288
- _this3.metaAtlasCore.setLastClickedFeature({
289
- mapObjectId: clickedFeature.properties.myMapObjectId,
290
- coordinates: coords,
291
- name: clickedFeature.properties.title,
292
- whatDimension: clickedFeature.properties.dimension_what,
293
- whereDimension: clickedFeature.properties.dimension_where,
294
- geometry: clickedFeature.geometry,
295
- properties: clickedFeature.properties,
296
- clickEvent: e
297
- });
298
- }
245
+ this.overRideSelectionOfDrawnPointGeometry(clickedFeature);
246
+ if (clickedFeature.properties.dimension_what.includes('what.infra.garden') || clickedFeature.properties.isSearchable && clickedFeature.properties.title != 'Transit' && clickedFeature.properties.title != 'Public') {
247
+ const coords = clickedFeature.geometry.type === "Polygon" || clickedFeature.geometry.type === "MultiPolygon" ? JSON.parse(clickedFeature.properties.center) : clickedFeature.geometry.coordinates;
248
+ this.metaAtlasCore.setLastClickedFeature({
249
+ mapObjectId: clickedFeature.properties.myMapObjectId,
250
+ coordinates: coords,
251
+ name: clickedFeature.properties.title,
252
+ whatDimension: clickedFeature.properties.dimension_what,
253
+ whereDimension: clickedFeature.properties.dimension_where,
254
+ geometry: clickedFeature.geometry,
255
+ properties: clickedFeature.properties,
256
+ clickEvent: e
299
257
  });
300
258
  }
301
- } catch (err) {
302
- _iterator2.e(err);
303
- } finally {
304
- _iterator2.f();
305
- }
306
- _this3.mapLoaded = true;
307
- _this3.setupMapBoxDraw();
308
- };
309
-
310
- // Check if map is already loaded (React mode with pre-existing map instance)
311
- if (this.map.loaded()) {
312
- // Map is already loaded, execute initialization directly
313
- setupLayers();
314
- } else {
315
- // Map not loaded yet, wait for load event (Vanilla mode)
316
- this.map.on('load', setupLayers);
317
- }
318
- this.map.on('error', function (error) {
319
- _this3.onLoadFail(error.message);
320
- });
321
- }
322
- }, {
323
- key: "setupMapBoxDraw",
324
- value: function setupMapBoxDraw() {
325
- var _this4 = this;
326
- this.mapBoxDraw = new _mapboxGlDraw["default"]({
327
- displayControlsDefault: false,
328
- userProperties: true,
329
- modes: _objectSpread(_objectSpread({}, _mapboxGlDraw["default"].modes), {}, {
330
- draw_marker: _draw_marker["default"],
331
- marker_select: _marker_select["default"]
332
- }),
333
- styles: _customStyles.mapBoxDrawDefaultStyles
334
- });
335
- this.map.addControl(this.mapBoxDraw);
336
- this.map.addSource(this.mapBoxDrawSourceID, {
337
- 'type': 'geojson',
338
- 'data': this.drawGeojsonData
339
- });
340
- for (var index = 0; index < _customStyles.customStyles.length; index++) {
341
- var element = _customStyles.customStyles[index];
342
- element['source'] = this.mapBoxDrawSourceID;
343
- this.map.addLayer(element);
344
- this.map.on('click', element.id, function (e) {
345
- _this4.metaAtlasCore.setLastClickedFeature({
346
- mapObjectId: null,
347
- coordinates: null,
348
- name: null,
349
- whatDimension: null,
350
- whereDimension: null,
351
- geometry: null,
352
- properties: null,
353
- clickEvent: e
354
- });
355
- var clickedFeature = e.features[0];
356
- _this4.overRideSelectionOfDrawnPointGeometry(clickedFeature);
357
- if (clickedFeature.properties.id) _this4.lastClickedDrawing = _this4.getDrawingById(clickedFeature.properties.id);else _this4.lastClickedDrawing = _this4.setDrawing();
358
259
  });
359
260
  }
360
261
  this.mapLoaded = true;
361
- this.onLoad();
362
- }
363
- }, {
364
- key: "overRideSelectionOfDrawnPointGeometry",
365
- value: function overRideSelectionOfDrawnPointGeometry(feature) {
366
- // Check if a drawn point geometry is currently selected, it will be consider selected both in highlighted & non-highlighted state.
367
- if (this.mapBoxDraw && this.mapBoxDraw.getMode() === 'simple_select' && this.mapBoxDraw.getAll().features.length === 1) {
368
- var mapBoxDrawFeature = this.mapBoxDraw.getAll().features;
369
- // If the passed in feature is not a drawn feature, then unselect drawn point type geometry
370
- if (feature.properties.id === undefined) this.mapBoxDraw.deleteAll();
371
- // If the passed in feature is a drawn feature, then unselect drawn point type geometry & highlight the passed in drawn geometry
372
- else if (feature.properties.id !== undefined && mapBoxDrawFeature[0].id !== feature.properties.id) {
373
- this.mapBoxDraw.deleteAll();
374
- var directSelectOptions = {
375
- featureId: feature.properties.id
376
- };
377
- // TODO: figure out why this doesn't work
378
- // this.mapBoxDraw.changeMode('direct_select', directSelectOptions)
379
- }
380
- }
381
- }
382
- }, {
383
- key: "getFocusTree",
384
- value: function getFocusTree() {
385
- return this.metaAtlasCore.getFocusTree();
386
- }
387
- }, {
388
- key: "setDrawing",
389
- value: function setDrawing() {
390
- var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
391
- var where = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
392
- var geom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
393
- var props = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
394
- var clickedFeature = {
395
- "id": id,
396
- "where": where,
397
- "geometry": geom,
398
- "properties": props
399
- };
400
- return clickedFeature;
401
- }
402
- }, {
403
- key: "getLastClickedFeature",
404
- value: function getLastClickedFeature() {
405
- return this.metaAtlasCore.getLastClickedFeature();
262
+ this.setupMapBoxDraw();
263
+ };
264
+
265
+ // Check if map is already loaded (React mode with pre-existing map instance)
266
+ if (this.map.loaded()) {
267
+ // Map is already loaded, execute initialization directly
268
+ setupLayers();
269
+ } else {
270
+ // Map not loaded yet, wait for load event (Vanilla mode)
271
+ this.map.on('load', setupLayers);
272
+ }
273
+ this.map.on('error', error => {
274
+ this.onLoadFail(error.message);
275
+ });
276
+ }
277
+ setupMapBoxDraw() {
278
+ this.mapBoxDraw = new _mapboxGlDraw.default({
279
+ displayControlsDefault: false,
280
+ userProperties: true,
281
+ modes: _objectSpread(_objectSpread({}, _mapboxGlDraw.default.modes), {}, {
282
+ draw_marker: _draw_marker.default,
283
+ marker_select: _marker_select.default
284
+ }),
285
+ styles: _customStyles.mapBoxDrawDefaultStyles
286
+ });
287
+ this.map.addControl(this.mapBoxDraw);
288
+ this.map.addSource(this.mapBoxDrawSourceID, {
289
+ 'type': 'geojson',
290
+ 'data': this.drawGeojsonData
291
+ });
292
+ for (let index = 0; index < _customStyles.customStyles.length; index++) {
293
+ const element = _customStyles.customStyles[index];
294
+ element['source'] = this.mapBoxDrawSourceID;
295
+ this.map.addLayer(element);
296
+ this.map.on('click', element.id, e => {
297
+ this.metaAtlasCore.setLastClickedFeature({
298
+ mapObjectId: null,
299
+ coordinates: null,
300
+ name: null,
301
+ whatDimension: null,
302
+ whereDimension: null,
303
+ geometry: null,
304
+ properties: null,
305
+ clickEvent: e
306
+ });
307
+ var clickedFeature = e.features[0];
308
+ this.overRideSelectionOfDrawnPointGeometry(clickedFeature);
309
+ if (clickedFeature.properties.id) this.lastClickedDrawing = this.getDrawingById(clickedFeature.properties.id);else this.lastClickedDrawing = this.setDrawing();
310
+ });
406
311
  }
407
- }, {
408
- key: "getLastClickedDrawing",
409
- value: function getLastClickedDrawing() {
410
- var clickedDrawing = this.lastClickedDrawing;
411
- if (!this.lastClickedDrawing || this.lastClickedDrawing && (this.lastClickedDrawing.id === null || this.lastClickedDrawing.where === null)) {
412
- clickedDrawing = this.setDrawing();
312
+ this.mapLoaded = true;
313
+ this.onLoad();
314
+ }
315
+ overRideSelectionOfDrawnPointGeometry(feature) {
316
+ // Check if a drawn point geometry is currently selected, it will be consider selected both in highlighted & non-highlighted state.
317
+ if (this.mapBoxDraw && this.mapBoxDraw.getMode() === 'simple_select' && this.mapBoxDraw.getAll().features.length === 1) {
318
+ const mapBoxDrawFeature = this.mapBoxDraw.getAll().features;
319
+ // If the passed in feature is not a drawn feature, then unselect drawn point type geometry
320
+ if (feature.properties.id === undefined) this.mapBoxDraw.deleteAll();
321
+ // If the passed in feature is a drawn feature, then unselect drawn point type geometry & highlight the passed in drawn geometry
322
+ else if (feature.properties.id !== undefined && mapBoxDrawFeature[0].id !== feature.properties.id) {
323
+ this.mapBoxDraw.deleteAll();
324
+ const directSelectOptions = {
325
+ featureId: feature.properties.id
326
+ };
327
+ // TODO: figure out why this doesn't work
328
+ // this.mapBoxDraw.changeMode('direct_select', directSelectOptions)
413
329
  }
414
- return clickedDrawing;
415
330
  }
416
- }, {
417
- key: "getMidPointOfFeature",
418
- value: function getMidPointOfFeature(feature) {
419
- return this.metaAtlasCore.getMidPointOfFeature(feature);
331
+ }
332
+ getFocusTree() {
333
+ return this.metaAtlasCore.getFocusTree();
334
+ }
335
+ setDrawing() {
336
+ let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
337
+ let where = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
338
+ let geom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
339
+ let props = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
340
+ const clickedFeature = {
341
+ "id": id,
342
+ "where": where,
343
+ "geometry": geom,
344
+ "properties": props
345
+ };
346
+ return clickedFeature;
347
+ }
348
+ getLastClickedFeature() {
349
+ return this.metaAtlasCore.getLastClickedFeature();
350
+ }
351
+ getLastClickedDrawing() {
352
+ let clickedDrawing = this.lastClickedDrawing;
353
+ if (!this.lastClickedDrawing || this.lastClickedDrawing && (this.lastClickedDrawing.id === null || this.lastClickedDrawing.where === null)) {
354
+ clickedDrawing = this.setDrawing();
420
355
  }
421
- }, {
422
- key: "dropPin",
423
- value: function dropPin(mapItemSelected, popupStyle) {
424
- var replaceLast = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
425
- var pinObj = {
426
- feature: mapItemSelected,
427
- popupStyle: popupStyle
428
- };
429
- var markerElement = document.createElement('div');
430
- markerElement.innerHTML = pinObj.popupStyle;
431
- var popup = new maplibregl.Marker({
432
- element: markerElement
433
- }).setLngLat(this.getMidPointOfFeature(pinObj.feature)).addTo(this.map);
434
- if (replaceLast) {
435
- if (this.popups.length > 1) {
436
- this.popups[this.popups.length - 1].popup.remove();
437
- this.popups[this.popups.length - 1].popup = popup;
438
- this.popups[this.popups.length - 1].id = pinObj.feature.mapObjectId;
439
- } else {
440
- if (this.popups.length > 0) this.popups[this.popups.length - 1].popup.remove();
441
- this.popups = [{
442
- popup: popup,
443
- id: pinObj.feature.mapObjectId
444
- }];
445
- }
356
+ return clickedDrawing;
357
+ }
358
+ getMidPointOfFeature(feature) {
359
+ return this.metaAtlasCore.getMidPointOfFeature(feature);
360
+ }
361
+ dropPin(mapItemSelected, popupStyle) {
362
+ let replaceLast = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
363
+ const pinObj = {
364
+ feature: mapItemSelected,
365
+ popupStyle: popupStyle
366
+ };
367
+ const markerElement = document.createElement('div');
368
+ markerElement.innerHTML = pinObj.popupStyle;
369
+ const popup = new maplibregl.Marker({
370
+ element: markerElement
371
+ }).setLngLat(this.getMidPointOfFeature(pinObj.feature)).addTo(this.map);
372
+ if (replaceLast) {
373
+ if (this.popups.length > 1) {
374
+ this.popups[this.popups.length - 1].popup.remove();
375
+ this.popups[this.popups.length - 1].popup = popup;
376
+ this.popups[this.popups.length - 1].id = pinObj.feature.mapObjectId;
446
377
  } else {
447
- this.popups.push({
378
+ if (this.popups.length > 0) this.popups[this.popups.length - 1].popup.remove();
379
+ this.popups = [{
448
380
  popup: popup,
449
381
  id: pinObj.feature.mapObjectId
450
- });
382
+ }];
451
383
  }
452
- return this.popups[this.popups.length - 1].id;
384
+ } else {
385
+ this.popups.push({
386
+ popup: popup,
387
+ id: pinObj.feature.mapObjectId
388
+ });
453
389
  }
454
- }, {
455
- key: "dropMarkerForRouting",
456
- value: function dropMarkerForRouting(destinations) {
457
- var _this5 = this;
458
- destinations.forEach(function (destination) {
459
- var _destination$selected, _destination$selected2;
460
- console.log(destination.selectedLocation, 'destination.selectedLocation');
461
- var coordinates = (_destination$selected = destination.selectedLocation) !== null && _destination$selected !== void 0 && _destination$selected.coordinates ? destination.selectedLocation.coordinates : (_destination$selected2 = destination.selectedLocation) === null || _destination$selected2 === void 0 || (_destination$selected2 = _destination$selected2.geometry) === null || _destination$selected2 === void 0 ? void 0 : _destination$selected2.coordinates;
462
- console.log(coordinates, 'Coordinates'); // Debugging line
390
+ return this.popups[this.popups.length - 1].id;
391
+ }
392
+ dropMarkerForRouting(destinations) {
393
+ destinations.forEach(destination => {
394
+ var _destination$selected, _destination$selected2;
395
+ console.log(destination.selectedLocation, 'destination.selectedLocation');
396
+ const coordinates = (_destination$selected = destination.selectedLocation) !== null && _destination$selected !== void 0 && _destination$selected.coordinates ? destination.selectedLocation.coordinates : (_destination$selected2 = destination.selectedLocation) === null || _destination$selected2 === void 0 || (_destination$selected2 = _destination$selected2.geometry) === null || _destination$selected2 === void 0 ? void 0 : _destination$selected2.coordinates;
397
+ console.log(coordinates, 'Coordinates'); // Debugging line
463
398
 
464
- if (coordinates && coordinates.length === 2) {
465
- var marker = new _this5.maplibregl.Marker({
466
- color: '#188689'
467
- }).setLngLat([coordinates[0], coordinates[1]]) // Ensure correct format
468
- .addTo(_this5.map);
469
- _this5.markers.push(marker);
470
- } else {
471
- console.error('Invalid coordinates:', coordinates);
472
- }
399
+ if (coordinates && coordinates.length === 2) {
400
+ const marker = new this.maplibregl.Marker({
401
+ color: '#188689'
402
+ }).setLngLat([coordinates[0], coordinates[1]]) // Ensure correct format
403
+ .addTo(this.map);
404
+ this.markers.push(marker);
405
+ } else {
406
+ console.error('Invalid coordinates:', coordinates);
407
+ }
408
+ });
409
+ }
410
+ clearMarker() {
411
+ if (this.markers && this.markers.length > 0) {
412
+ this.markers.forEach(marker => {
413
+ marker.remove();
473
414
  });
474
415
  }
475
- }, {
476
- key: "clearMarker",
477
- value: function clearMarker() {
478
- if (this.markers && this.markers.length > 0) {
479
- this.markers.forEach(function (marker) {
480
- marker.remove();
481
- });
416
+ this.markers = [];
417
+ }
418
+ extractLocation(text) {
419
+ const match = text.match(/^(?:[^_]*_){3}([^_]*)/);
420
+ return match ? match[1] : null;
421
+ }
422
+ hidePin() {
423
+ let pinId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '-1';
424
+ let targetPinId;
425
+ if (pinId === '-1') {
426
+ const lastPin = this.popups[this.popups.length - 1];
427
+ if (!lastPin) {
428
+ console.warn('No pins available to hide.');
429
+ return;
482
430
  }
483
- this.markers = [];
431
+ targetPinId = lastPin.id;
432
+ } else {
433
+ targetPinId = pinId;
484
434
  }
485
- }, {
486
- key: "extractLocation",
487
- value: function extractLocation(text) {
488
- var match = text.match(/^(?:[^_]*_){3}([^_]*)/);
489
- return match ? match[1] : null;
490
- }
491
- }, {
492
- key: "hidePin",
493
- value: function hidePin() {
494
- var pinId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '-1';
495
- var targetPinId;
496
- if (pinId === '-1') {
497
- var lastPin = this.popups[this.popups.length - 1];
498
- if (!lastPin) {
499
- console.warn('No pins available to hide.');
500
- return;
501
- }
502
- targetPinId = lastPin.id;
503
- } else {
504
- targetPinId = pinId;
435
+ const pinToHide = this.popups.find(pin => pin.id === targetPinId);
436
+ if (pinToHide) {
437
+ let popupElem = pinToHide.popup.getElement();
438
+ if (popupElem) {
439
+ popupElem.style.display = 'none';
505
440
  }
506
- var pinToHide = this.popups.find(function (pin) {
507
- return pin.id === targetPinId;
508
- });
509
- if (pinToHide) {
510
- var popupElem = pinToHide.popup.getElement();
441
+ console.log("Pin with ID: ".concat(targetPinId, " is now hidden."));
442
+ } else {
443
+ console.warn("Pin with ID: ".concat(targetPinId, " not found."));
444
+ }
445
+ }
446
+ hidePins() {
447
+ if (this.popups.length > 0) {
448
+ this.popups.forEach(obj => {
449
+ let popupElem = obj.popup.getElement();
511
450
  if (popupElem) {
451
+ console.log(popupElem.style.display);
512
452
  popupElem.style.display = 'none';
513
453
  }
514
- console.log("Pin with ID: ".concat(targetPinId, " is now hidden."));
515
- } else {
516
- console.warn("Pin with ID: ".concat(targetPinId, " not found."));
517
- }
454
+ });
518
455
  }
519
- }, {
520
- key: "hidePins",
521
- value: function hidePins() {
522
- if (this.popups.length > 0) {
523
- this.popups.forEach(function (obj) {
524
- var popupElem = obj.popup.getElement();
525
- if (popupElem) {
526
- console.log(popupElem.style.display);
527
- popupElem.style.display = 'none';
528
- }
529
- });
456
+ }
457
+ showPin() {
458
+ let pinId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '-1';
459
+ let targetPinId;
460
+ if (pinId === '-1') {
461
+ const lastPin = this.popups[this.popups.length - 1];
462
+ if (!lastPin) {
463
+ console.warn('No pins available to show.');
464
+ return;
530
465
  }
466
+ targetPinId = lastPin.id;
467
+ } else {
468
+ targetPinId = pinId;
531
469
  }
532
- }, {
533
- key: "showPin",
534
- value: function showPin() {
535
- var pinId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '-1';
536
- var targetPinId;
537
- if (pinId === '-1') {
538
- var lastPin = this.popups[this.popups.length - 1];
539
- if (!lastPin) {
540
- console.warn('No pins available to show.');
541
- return;
542
- }
543
- targetPinId = lastPin.id;
544
- } else {
545
- targetPinId = pinId;
470
+ const pinToHide = this.popups.find(pin => pin.id === targetPinId);
471
+ if (pinToHide) {
472
+ let popupElem = pinToHide.popup.getElement();
473
+ if (popupElem) {
474
+ popupElem.style.display = 'flex';
546
475
  }
547
- var pinToHide = this.popups.find(function (pin) {
548
- return pin.id === targetPinId;
549
- });
550
- if (pinToHide) {
551
- var popupElem = pinToHide.popup.getElement();
476
+ console.log("Pin with ID: ".concat(targetPinId, " is now visible."));
477
+ } else {
478
+ console.warn("Pin with ID: ".concat(targetPinId, " not found."));
479
+ }
480
+ }
481
+ showPins() {
482
+ if (this.popups.length > 0) {
483
+ this.popups.forEach(obj => {
484
+ let popupElem = obj.popup.getElement();
552
485
  if (popupElem) {
553
486
  popupElem.style.display = 'flex';
554
487
  }
555
- console.log("Pin with ID: ".concat(targetPinId, " is now visible."));
556
- } else {
557
- console.warn("Pin with ID: ".concat(targetPinId, " not found."));
558
- }
559
- }
560
- }, {
561
- key: "showPins",
562
- value: function showPins() {
563
- if (this.popups.length > 0) {
564
- this.popups.forEach(function (obj) {
565
- var popupElem = obj.popup.getElement();
566
- if (popupElem) {
567
- popupElem.style.display = 'flex';
568
- }
569
- });
570
- }
488
+ });
571
489
  }
572
- }, {
573
- key: "clearPin",
574
- value: function clearPin() {
575
- var pinId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '-1';
576
- var targetPinIndex;
577
- if (pinId === '-1') {
578
- targetPinIndex = this.popups.length - 1;
579
- if (targetPinIndex < 0) {
580
- console.warn('No pins available to clear.');
581
- return;
582
- }
583
- } else {
584
- targetPinIndex = this.popups.findIndex(function (pin) {
585
- return pin.id === pinId;
586
- });
587
- if (targetPinIndex === -1) {
588
- console.warn("Pin with ID: ".concat(pinId, " not found."));
589
- return;
590
- }
591
- }
592
- if (this.popups[targetPinIndex]) {
593
- this.popups[targetPinIndex].popup.remove();
594
- this.popups.splice(targetPinIndex, 1);
490
+ }
491
+ clearPin() {
492
+ let pinId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '-1';
493
+ let targetPinIndex;
494
+ if (pinId === '-1') {
495
+ targetPinIndex = this.popups.length - 1;
496
+ if (targetPinIndex < 0) {
497
+ console.warn('No pins available to clear.');
498
+ return;
595
499
  }
596
- }
597
- }, {
598
- key: "clearPins",
599
- value: function clearPins() {
600
- if (this.popups.length > 0) {
601
- this.popups.forEach(function (obj) {
602
- obj.popup.remove();
603
- });
604
- this.popups.length = 0;
500
+ } else {
501
+ targetPinIndex = this.popups.findIndex(pin => pin.id === pinId);
502
+ if (targetPinIndex === -1) {
503
+ console.warn("Pin with ID: ".concat(pinId, " not found."));
504
+ return;
605
505
  }
606
506
  }
607
- }, {
608
- key: "removePin",
609
- value: function removePin() {
610
- (0, _jquery["default"])('.mapboxgl-popup').remove();
507
+ if (this.popups[targetPinIndex]) {
508
+ this.popups[targetPinIndex].popup.remove();
509
+ this.popups.splice(targetPinIndex, 1);
611
510
  }
612
- }, {
613
- key: "getCurrentFocus",
614
- value: function getCurrentFocus() {
615
- return this.metaAtlasCore.getCurrentFocus();
616
- }
617
- }, {
618
- key: "getCurrentFocusBuilding",
619
- value: function getCurrentFocusBuilding() {
620
- return this.metaAtlasCore.getCurrentFocusBuilding();
621
- }
622
- }, {
623
- key: "getCurrentFocusFloor",
624
- value: function getCurrentFocusFloor() {
625
- return this.metaAtlasCore.getCurrentFocusFloor();
626
- }
627
- }, {
628
- key: "addUserLayer",
629
- value: function addUserLayer(layer) {
630
- var _this6 = this;
631
- this.UserLayers.push(layer);
632
- this.map.addLayer(layer);
633
- this.map.on('click', layer.id, function (e) {
634
- //setup new clicked feature
635
- var clickedFeature = e.features[0];
636
- var coords = clickedFeature.geometry.type === "Polygon" ? JSON.parse(clickedFeature.properties.center) : clickedFeature.geometry.coordinates;
637
- _this6.metaAtlasCore.setLastClickedFeature({
638
- mapObjectId: clickedFeature.properties.id,
639
- coordinates: coords,
640
- name: clickedFeature.properties.name,
641
- whatDimension: clickedFeature.properties.dimension_what,
642
- whereDimension: clickedFeature.properties.dimension_where,
643
- geometry: clickedFeature.geometry,
644
- properties: clickedFeature.properties,
645
- clickEvent: e
646
- });
511
+ }
512
+ clearPins() {
513
+ if (this.popups.length > 0) {
514
+ this.popups.forEach(obj => {
515
+ obj.popup.remove();
647
516
  });
517
+ this.popups.length = 0;
648
518
  }
649
- }, {
650
- key: "filterWhereDimension",
651
- value: function filterWhereDimension(dimensionWhere) {
652
- // filter user layers
653
- var userLayers = (0, _cloneDeep["default"])(this.UserLayers);
654
- if (userLayers.length > 0) {
655
- var updatedUserLayersData = this.metaAtlasCore.filterBaseMapWhereDimension(userLayers, dimensionWhere);
656
- for (var index = 0; index < updatedUserLayersData.length; index++) {
657
- var layerID = updatedUserLayersData[index].id;
658
- var layerFilter = updatedUserLayersData[index].filter;
659
- userLayers[index].filter = layerFilter;
660
- this.map.setFilter(layerID, layerFilter);
661
- }
519
+ }
520
+ removePin() {
521
+ (0, _jquery.default)('.mapboxgl-popup').remove();
522
+ }
523
+ getCurrentFocus() {
524
+ return this.metaAtlasCore.getCurrentFocus();
525
+ }
526
+ getCurrentFocusBuilding() {
527
+ return this.metaAtlasCore.getCurrentFocusBuilding();
528
+ }
529
+ getCurrentFocusFloor() {
530
+ return this.metaAtlasCore.getCurrentFocusFloor();
531
+ }
532
+ addUserLayer(layer) {
533
+ this.UserLayers.push(layer);
534
+ this.map.addLayer(layer);
535
+ this.map.on('click', layer.id, e => {
536
+ //setup new clicked feature
537
+ var clickedFeature = e.features[0];
538
+ const coords = clickedFeature.geometry.type === "Polygon" ? JSON.parse(clickedFeature.properties.center) : clickedFeature.geometry.coordinates;
539
+ this.metaAtlasCore.setLastClickedFeature({
540
+ mapObjectId: clickedFeature.properties.id,
541
+ coordinates: coords,
542
+ name: clickedFeature.properties.name,
543
+ whatDimension: clickedFeature.properties.dimension_what,
544
+ whereDimension: clickedFeature.properties.dimension_where,
545
+ geometry: clickedFeature.geometry,
546
+ properties: clickedFeature.properties,
547
+ clickEvent: e
548
+ });
549
+ });
550
+ }
551
+ filterWhereDimension(dimensionWhere) {
552
+ // filter user layers
553
+ let userLayers = (0, _cloneDeep.default)(this.UserLayers);
554
+ if (userLayers.length > 0) {
555
+ let updatedUserLayersData = this.metaAtlasCore.filterBaseMapWhereDimension(userLayers, dimensionWhere);
556
+ for (let index = 0; index < updatedUserLayersData.length; index++) {
557
+ const layerID = updatedUserLayersData[index].id;
558
+ const layerFilter = updatedUserLayersData[index].filter;
559
+ userLayers[index].filter = layerFilter;
560
+ this.map.setFilter(layerID, layerFilter);
662
561
  }
562
+ }
663
563
 
664
- // filter basemap layers
665
- var layers = (0, _cloneDeep["default"])(this.CustomerLayers);
666
- for (var _index = 0; _index < layers.length; _index += 1) {
667
- var _layerID = layers[_index].id;
668
- var _layerFilter = this.map.getFilter(_layerID);
669
- layers[_index].filter = _layerFilter;
670
- }
671
- var updatedLayersData = this.metaAtlasCore.filterBaseMapWhereDimension(layers, dimensionWhere);
672
- for (var _index2 = 0; _index2 < updatedLayersData.length; _index2 += 1) {
673
- var _layerID2 = updatedLayersData[_index2].id;
674
- var _layerFilter2 = updatedLayersData[_index2].filter;
675
- this.map.setFilter(_layerID2, _layerFilter2);
676
- }
564
+ // filter basemap layers
565
+ let layers = (0, _cloneDeep.default)(this.CustomerLayers);
566
+ for (let index = 0; index < layers.length; index += 1) {
567
+ const layerID = layers[index].id;
568
+ const layerFilter = this.map.getFilter(layerID);
569
+ layers[index].filter = layerFilter;
570
+ }
571
+ let updatedLayersData = this.metaAtlasCore.filterBaseMapWhereDimension(layers, dimensionWhere);
572
+ for (let index = 0; index < updatedLayersData.length; index += 1) {
573
+ const layerID = updatedLayersData[index].id;
574
+ const layerFilter = updatedLayersData[index].filter;
575
+ this.map.setFilter(layerID, layerFilter);
576
+ }
677
577
 
678
- // // filter non-basemap layers
679
- // layers = cloneDeep(customStyles.concat(routeLayers));
680
- // for (let index = 0; index < layers.length; index += 1) {
681
- // const layerID = layers[index].id;
682
- // const layerFilter = this.map.getFilter(layerID);
683
- // layers[index].filter = layerFilter;
684
- // }
685
- // updatedLayersData =
686
- // this.metaAtlasCore.filterLayersWhereDimension(
687
- // layers,
688
- // dimensionWhere,
689
- // );
578
+ // // filter non-basemap layers
579
+ // layers = cloneDeep(customStyles.concat(routeLayers));
580
+ // for (let index = 0; index < layers.length; index += 1) {
581
+ // const layerID = layers[index].id;
582
+ // const layerFilter = this.map.getFilter(layerID);
583
+ // layers[index].filter = layerFilter;
584
+ // }
585
+ // updatedLayersData =
586
+ // this.metaAtlasCore.filterLayersWhereDimension(
587
+ // layers,
588
+ // dimensionWhere,
589
+ // );
690
590
 
691
- // for (let index = 0; index < updatedLayersData.length; index += 1) {
692
- // const layerID = updatedLayersData[index].id;
693
- // const layerFilter = updatedLayersData[index].filter;
694
- // }
695
- }
696
- }, {
697
- key: "focusTo",
698
- value: function focusTo(whereTaxonomyPath) {
699
- var moveCamera = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
700
- var map = this.map;
701
- var dimensionWhere = whereTaxonomyPath;
702
- if (!dimensionWhere || !map) return;
703
- console.log(whereTaxonomyPath, 'whereTaxonomyPath');
704
- this.filterWhereDimension(dimensionWhere);
705
- var isMobile = window.innerWidth < 768;
706
- if (moveCamera) {
707
- var flyToConfig = this.metaAtlasCore.getFlyToLocation(dimensionWhere, isMobile);
708
- this.map.flyTo({
709
- center: flyToConfig.center ? flyToConfig.center : this.map.getCenter(),
710
- zoom: flyToConfig.zoom ? flyToConfig.zoom : this.map.getZoom(),
711
- bearing: flyToConfig.bearing ? flyToConfig.bearing : this.map.getBearing(),
712
- speed: 0.8
713
- });
591
+ // for (let index = 0; index < updatedLayersData.length; index += 1) {
592
+ // const layerID = updatedLayersData[index].id;
593
+ // const layerFilter = updatedLayersData[index].filter;
594
+ // }
595
+ }
596
+ focusTo(whereTaxonomyPath) {
597
+ let moveCamera = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
598
+ const map = this.map;
599
+ let dimensionWhere = whereTaxonomyPath;
600
+ if (!dimensionWhere || !map) return;
601
+ console.log(whereTaxonomyPath, 'whereTaxonomyPath');
602
+ this.filterWhereDimension(dimensionWhere);
603
+ const isMobile = window.innerWidth < 768;
604
+ if (moveCamera) {
605
+ const flyToConfig = this.metaAtlasCore.getFlyToLocation(dimensionWhere, isMobile);
606
+ this.map.flyTo({
607
+ center: flyToConfig.center ? flyToConfig.center : this.map.getCenter(),
608
+ zoom: flyToConfig.zoom ? flyToConfig.zoom : this.map.getZoom(),
609
+ bearing: flyToConfig.bearing ? flyToConfig.bearing : this.map.getBearing(),
610
+ speed: 0.8
611
+ });
714
612
 
715
- // track inside so that only user requested focus is tracked
716
- // logEvent(this.analytics, 'focus_changed', { location: dimensionWhere });
717
- }
613
+ // track inside so that only user requested focus is tracked
614
+ // logEvent(this.analytics, 'focus_changed', { location: dimensionWhere });
718
615
  }
719
- }, {
720
- key: "filterLayersByCategories",
721
- value: function filterLayersByCategories(filterType, filterValues, geomType, dimensionWhat) {
722
- var map = this.map;
723
- if (!filterValues || !map) return;
724
- var layers = (0, _cloneDeep["default"])(this.CustomerLayers);
725
- for (var index = 0; index < layers.length; index += 1) {
726
- var layerID = layers[index].id;
727
- var layerFilter = this.map.getFilter(layerID);
728
- layers[index].filter = layerFilter;
729
- }
730
- var updatedLayersData = this.metaAtlasCore.filterLayersByCategories(layers, filterType, filterValues, geomType, dimensionWhat, this.map);
731
- for (var _index3 = 0; _index3 < updatedLayersData.length; _index3 += 1) {
732
- var _layerID3 = updatedLayersData[_index3].id;
733
- var _layerFilter3 = updatedLayersData[_index3].filter;
734
- this.map.setFilter(_layerID3, _layerFilter3);
735
- }
616
+ }
617
+ filterLayersByCategories(filterType, filterValues, geomType, dimensionWhat) {
618
+ const map = this.map;
619
+ if (!filterValues || !map) return;
620
+ let layers = (0, _cloneDeep.default)(this.CustomerLayers);
621
+ for (let index = 0; index < layers.length; index += 1) {
622
+ const layerID = layers[index].id;
623
+ const layerFilter = this.map.getFilter(layerID);
624
+ layers[index].filter = layerFilter;
625
+ }
626
+ let updatedLayersData = this.metaAtlasCore.filterLayersByCategories(layers, filterType, filterValues, geomType, dimensionWhat, this.map);
627
+ for (let index = 0; index < updatedLayersData.length; index += 1) {
628
+ const layerID = updatedLayersData[index].id;
629
+ const layerFilter = updatedLayersData[index].filter;
630
+ this.map.setFilter(layerID, layerFilter);
736
631
  }
737
- }, {
738
- key: "filterLayersByType",
739
- value: function filterLayersByType(filterType, filterValues) {
740
- var geomType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
741
- var map = this.map;
742
- if (!filterValues || !map) return;
743
- var userLayers = (0, _cloneDeep["default"])(this.UserLayers);
744
- if (userLayers.length > 0) {
745
- var updatedUserLayersData = this.metaAtlasCore.filterLayersByType(userLayers, filterType, filterValues, geomType);
746
- for (var index = 0; index < updatedUserLayersData.length; index++) {
747
- var layerID = updatedUserLayersData[index].id;
748
- var layerFilter = updatedUserLayersData[index].filter;
749
- userLayers[index].filter = layerFilter;
750
- this.map.setFilter(layerID, layerFilter);
751
- }
632
+ }
633
+ filterLayersByType(filterType, filterValues) {
634
+ let geomType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
635
+ const map = this.map;
636
+ if (!filterValues || !map) return;
637
+ let userLayers = (0, _cloneDeep.default)(this.UserLayers);
638
+ if (userLayers.length > 0) {
639
+ let updatedUserLayersData = this.metaAtlasCore.filterLayersByType(userLayers, filterType, filterValues, geomType);
640
+ for (let index = 0; index < updatedUserLayersData.length; index++) {
641
+ const layerID = updatedUserLayersData[index].id;
642
+ const layerFilter = updatedUserLayersData[index].filter;
643
+ userLayers[index].filter = layerFilter;
644
+ this.map.setFilter(layerID, layerFilter);
752
645
  }
753
646
  }
754
- }, {
755
- key: "styleLayersByType",
756
- value: function styleLayersByType(filterType, filterValues, property, value) {
757
- if (!filterValues || !this.map) return;
758
- var styleJson = this.map.getStyle();
759
- var layers = styleJson.layers;
760
- var updatedLayersData = this.metaAtlasCore.styleLayersByType(layers, filterType, filterValues, property, value);
761
- for (var index = 0; index < updatedLayersData.length; index += 1) {
762
- var layerID = updatedLayersData[index].id;
763
- var layerStyle = updatedLayersData[index].paint;
764
- var layerType = updatedLayersData[index].type;
765
- if (layerType && (layerType === 'fill' || layerType === 'line')) {
766
- if (layerStyle[property]) {
767
- this.map.setPaintProperty(layerID, property, layerStyle[property]);
768
- }
647
+ }
648
+ styleLayersByType(filterType, filterValues, property, value) {
649
+ if (!filterValues || !this.map) return;
650
+ let styleJson = this.map.getStyle();
651
+ let layers = styleJson.layers;
652
+ let updatedLayersData = this.metaAtlasCore.styleLayersByType(layers, filterType, filterValues, property, value);
653
+ for (let index = 0; index < updatedLayersData.length; index += 1) {
654
+ const layerID = updatedLayersData[index].id;
655
+ const layerStyle = updatedLayersData[index].paint;
656
+ const layerType = updatedLayersData[index].type;
657
+ if (layerType && (layerType === 'fill' || layerType === 'line')) {
658
+ if (layerStyle[property]) {
659
+ this.map.setPaintProperty(layerID, property, layerStyle[property]);
769
660
  }
770
661
  }
771
662
  }
772
- }, {
773
- key: "clearStyleLayersByType",
774
- value: function clearStyleLayersByType(filterType, filterValues, property) {
775
- if (!this.map) return;
776
- var styleJson = this.map.getStyle();
777
- var layers = styleJson.layers;
778
- var updatedLayersData = this.metaAtlasCore.clearStyleLayersByType(layers, filterType, filterValues, property);
779
- for (var index = 0; index < updatedLayersData.length; index += 1) {
780
- var layerID = updatedLayersData[index].id;
781
- var layerStyle = updatedLayersData[index].paint;
782
- var layerType = updatedLayersData[index].type;
783
- if (layerType && (layerType === 'fill' || layerType === 'line')) {
784
- if (layerStyle[property]) {
785
- this.map.setPaintProperty(layerID, property, layerStyle[property]);
786
- }
663
+ }
664
+ clearStyleLayersByType(filterType, filterValues, property) {
665
+ if (!this.map) return;
666
+ let styleJson = this.map.getStyle();
667
+ let layers = styleJson.layers;
668
+ let updatedLayersData = this.metaAtlasCore.clearStyleLayersByType(layers, filterType, filterValues, property);
669
+ for (let index = 0; index < updatedLayersData.length; index += 1) {
670
+ const layerID = updatedLayersData[index].id;
671
+ const layerStyle = updatedLayersData[index].paint;
672
+ const layerType = updatedLayersData[index].type;
673
+ if (layerType && (layerType === 'fill' || layerType === 'line')) {
674
+ if (layerStyle[property]) {
675
+ this.map.setPaintProperty(layerID, property, layerStyle[property]);
787
676
  }
788
677
  }
789
678
  }
790
- }, {
791
- key: "changeTerminalInFocusToUserViewpoint",
792
- value: function changeTerminalInFocusToUserViewpoint() {
793
- var defaultFloor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
794
- var center = this.map.getCenter().wrap();
795
- var centerArray = [center.lng, center.lat];
796
- // console.log('center: ', center);
797
- if (this.metaAtlasCore.checkUserViewport(centerArray, this.getCurrentFocusBuilding(), this.getCurrentFocusFloor())) return true;
798
- //get building to focus to
799
- var building = this.metaAtlasCore.getUserViewportBuilding(centerArray);
800
- // console.log("focus to:");
801
- // console.log(building);
802
- if (!building) return false;
803
- //focus to default floor provided
804
- if (building["name"] in defaultFloor) {
805
- this.focusTo(defaultFloor[building["name"]], false);
806
- return true;
807
- }
808
- //focus to default floor in focusTree
809
- // if (!building.hasOwnProperty("defaultFloorPath")) return true;
810
- // this.focusTo(building["defaultFloorPath"], false);
811
-
679
+ }
680
+ changeTerminalInFocusToUserViewpoint() {
681
+ let defaultFloor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
682
+ let center = this.map.getCenter().wrap();
683
+ const centerArray = [center.lng, center.lat];
684
+ // console.log('center: ', center);
685
+ if (this.metaAtlasCore.checkUserViewport(centerArray, this.getCurrentFocusBuilding(), this.getCurrentFocusFloor())) return true;
686
+ //get building to focus to
687
+ let building = this.metaAtlasCore.getUserViewportBuilding(centerArray);
688
+ // console.log("focus to:");
689
+ // console.log(building);
690
+ if (!building) return false;
691
+ //focus to default floor provided
692
+ if (building["name"] in defaultFloor) {
693
+ this.focusTo(defaultFloor[building["name"]], false);
812
694
  return true;
813
695
  }
814
- }, {
815
- key: "isLocationWithinHongKong",
816
- value: function isLocationWithinHongKong(location) {
817
- // Define the polygon coordinates
818
- var polygonCoordinates = [[103.59716039266556, 1.2570288388163817], [103.5792058079661, 1.2001127572538621], [103.69481581677104, 1.2005505778590049], [103.9124604166791, 1.2408297702235416], [104.07843084598773, 1.3003717948835174], [104.09332001378709, 1.3428384139758691], [104.06568408463107, 1.4395702492902842], [104.01405273250049, 1.430831826129534], [103.94486100905976, 1.4264524124152587], [103.88661860370877, 1.4347670822090777], [103.84020398120549, 1.470670314084117], [103.79466396668937, 1.467591709607774], [103.75700361138325, 1.4470255906078648], [103.72197278477057, 1.4605952336399213], [103.68041038922672, 1.4408697939934143], [103.64577440712543, 1.379174061413977], [103.59716039266556, 1.2570288388163817], [103.59716039266556, 1.2570288388163817] // Close the polygon by repeating the first point
819
- ];
696
+ //focus to default floor in focusTree
697
+ // if (!building.hasOwnProperty("defaultFloorPath")) return true;
698
+ // this.focusTo(building["defaultFloorPath"], false);
820
699
 
821
- // Create the polygon using Turf.js
822
- var polygon = (0, _helpers.polygon)([polygonCoordinates]);
700
+ return true;
701
+ }
702
+ isLocationWithinHongKong(location) {
703
+ // Define the polygon coordinates
704
+ const polygonCoordinates = [[103.59716039266556, 1.2570288388163817], [103.5792058079661, 1.2001127572538621], [103.69481581677104, 1.2005505778590049], [103.9124604166791, 1.2408297702235416], [104.07843084598773, 1.3003717948835174], [104.09332001378709, 1.3428384139758691], [104.06568408463107, 1.4395702492902842], [104.01405273250049, 1.430831826129534], [103.94486100905976, 1.4264524124152587], [103.88661860370877, 1.4347670822090777], [103.84020398120549, 1.470670314084117], [103.79466396668937, 1.467591709607774], [103.75700361138325, 1.4470255906078648], [103.72197278477057, 1.4605952336399213], [103.68041038922672, 1.4408697939934143], [103.64577440712543, 1.379174061413977], [103.59716039266556, 1.2570288388163817], [103.59716039266556, 1.2570288388163817] // Close the polygon by repeating the first point
705
+ ];
823
706
 
824
- // Define the point to check
825
- var point = (0, _helpers.point)(location); // Replace with your point's coordinates
707
+ // Create the polygon using Turf.js
708
+ const polygon = (0, _helpers.polygon)([polygonCoordinates]);
826
709
 
827
- // Check if the point is within the polygon
828
- var isInside = (0, _booleanPointInPolygon["default"])(point, polygon);
829
- return isInside;
830
- }
831
- }, {
832
- key: "getMapObjectsByFilteredLocalRef",
833
- value: function getMapObjectsByFilteredLocalRef() {
834
- var _this$metaAtlasCore;
835
- return (_this$metaAtlasCore = this.metaAtlasCore).getMapObjectsByFilteredLocalRef.apply(_this$metaAtlasCore, arguments);
836
- }
837
- }, {
838
- key: "getMapObjectsByName",
839
- value: function getMapObjectsByName() {
840
- var _this$metaAtlasCore2;
841
- return (_this$metaAtlasCore2 = this.metaAtlasCore).getMapObjectsByName.apply(_this$metaAtlasCore2, arguments);
842
- }
843
- }, {
844
- key: "getMapObjectById",
845
- value: function getMapObjectById() {
846
- var _this$metaAtlasCore3;
847
- return (_this$metaAtlasCore3 = this.metaAtlasCore).getMapObjectById.apply(_this$metaAtlasCore3, arguments);
848
- }
849
- }, {
850
- key: "getMapObjectByLocalRef",
851
- value: function getMapObjectByLocalRef() {
852
- var _this$metaAtlasCore4;
853
- return (_this$metaAtlasCore4 = this.metaAtlasCore).getMapObjectByLocalRef.apply(_this$metaAtlasCore4, arguments);
854
- }
855
- }, {
856
- key: "getMapObjectMatchingLocalRef",
857
- value: function getMapObjectMatchingLocalRef() {
858
- var _this$metaAtlasCore5;
859
- return (_this$metaAtlasCore5 = this.metaAtlasCore).getMapObjectMatchingLocalRef.apply(_this$metaAtlasCore5, arguments);
860
- }
861
- }, {
862
- key: "getMapObjectsMatchingLocalRefs",
863
- value: function getMapObjectsMatchingLocalRefs() {
864
- var _this$metaAtlasCore6;
865
- return (_this$metaAtlasCore6 = this.metaAtlasCore).getMapObjectsMatchingLocalRefs.apply(_this$metaAtlasCore6, arguments);
866
- }
867
- }, {
868
- key: "getMapObjectsByWhatTaxonomy",
869
- value: function getMapObjectsByWhatTaxonomy() {
870
- var _this$metaAtlasCore7;
871
- return (_this$metaAtlasCore7 = this.metaAtlasCore).getMapObjectsByWhatTaxonomy.apply(_this$metaAtlasCore7, arguments);
872
- }
873
- }, {
874
- key: "getMapObjectsByWhatTaxonomyAPI",
875
- value: function getMapObjectsByWhatTaxonomyAPI() {
876
- var _this$metaAtlasCore8;
877
- return (_this$metaAtlasCore8 = this.metaAtlasCore).getMapObjectsByWhatTaxonomyAPI.apply(_this$metaAtlasCore8, arguments);
878
- }
879
- }, {
880
- key: "getMapObjectsByWhereTaxonomy",
881
- value: function getMapObjectsByWhereTaxonomy() {
882
- var _this$metaAtlasCore9;
883
- return (_this$metaAtlasCore9 = this.metaAtlasCore).getMapObjectsByWhereTaxonomy.apply(_this$metaAtlasCore9, arguments);
884
- }
885
- }, {
886
- key: "getMapObjectsByWhatAndWhereTaxonomy",
887
- value: function getMapObjectsByWhatAndWhereTaxonomy() {
888
- var _this$metaAtlasCore0;
889
- return (_this$metaAtlasCore0 = this.metaAtlasCore).getMapObjectsByWhatAndWhereTaxonomy.apply(_this$metaAtlasCore0, arguments);
890
- }
891
- }, {
892
- key: "getMapObjectsInWhatTaxonomy",
893
- value: function getMapObjectsInWhatTaxonomy() {
894
- var _this$metaAtlasCore1;
895
- return (_this$metaAtlasCore1 = this.metaAtlasCore).getMapObjectsInWhatTaxonomy.apply(_this$metaAtlasCore1, arguments);
896
- }
897
- }, {
898
- key: "getMapObjectsInWhereTaxonomy",
899
- value: function getMapObjectsInWhereTaxonomy() {
900
- var _this$metaAtlasCore10;
901
- return (_this$metaAtlasCore10 = this.metaAtlasCore).getMapObjectsInWhereTaxonomy.apply(_this$metaAtlasCore10, arguments);
902
- }
710
+ // Define the point to check
711
+ const point = (0, _helpers.point)(location); // Replace with your point's coordinates
903
712
 
904
- // Routing
905
- }, {
906
- key: "computeRoute",
907
- value: function computeRoute() {
908
- var _this$routingVisualiz;
909
- return (_this$routingVisualiz = this.routingVisualizer).computeRoute.apply(_this$routingVisualiz, arguments);
910
- }
911
- }, {
912
- key: "computeRoutes",
913
- value: function computeRoutes(mapObjectIds) {
914
- var _this7 = this;
915
- var wheelChairAccessibleRouteOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
916
- var source = arguments.length > 2 ? arguments[2] : undefined;
917
- var ref = this;
918
- var logRouteEvent = /*#__PURE__*/function () {
919
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
920
- var getNameByIdAsync, getNamesFromIds, names;
921
- return _regenerator().w(function (_context2) {
922
- while (1) switch (_context2.n) {
923
- case 0:
924
- getNameByIdAsync = function getNameByIdAsync(id) {
925
- return new Promise(function (resolve) {
926
- if (typeof id !== 'string') resolve('User GPS Location');
927
- ref.getMapObjectById(id, function (mapObj) {
928
- var _mapObj$;
929
- resolve((_mapObj$ = mapObj[0]) === null || _mapObj$ === void 0 ? void 0 : _mapObj$.name);
930
- });
931
- });
932
- };
933
- getNamesFromIds = /*#__PURE__*/function () {
934
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(idList) {
935
- var namePromises;
936
- return _regenerator().w(function (_context) {
937
- while (1) switch (_context.n) {
938
- case 0:
939
- namePromises = idList.map(function (id) {
940
- return getNameByIdAsync(id);
941
- });
942
- _context.n = 1;
943
- return Promise.all(namePromises);
944
- case 1:
945
- return _context.a(2, _context.v);
946
- }
947
- }, _callee);
948
- }));
949
- return function getNamesFromIds(_x) {
950
- return _ref2.apply(this, arguments);
951
- };
952
- }();
953
- _context2.n = 1;
954
- return getNamesFromIds(mapObjectIds);
955
- case 1:
956
- names = _context2.v;
957
- names.forEach(function (name) {
958
- _this7.logAnalyticsEvent('route_per_object', {
959
- destination: name,
960
- route_per_object_event_source: source
961
- });
962
- });
963
- _this7.logAnalyticsEvent('route', {
964
- destinations: names,
965
- route_event_source: source
966
- });
967
- case 2:
968
- return _context2.a(2);
969
- }
970
- }, _callee2);
971
- }));
972
- return function logRouteEvent() {
973
- return _ref.apply(this, arguments);
974
- };
975
- }();
976
- logRouteEvent();
977
- return this.routingVisualizer.computeRoutes(mapObjectIds, wheelChairAccessibleRouteOnly);
978
- }
979
- }, {
980
- key: "setActiveRoute",
981
- value: function setActiveRoute() {
982
- var _this$routingVisualiz2;
983
- return (_this$routingVisualiz2 = this.routingVisualizer).setActiveRoute.apply(_this$routingVisualiz2, arguments);
984
- }
985
- }, {
986
- key: "getActiveRoute",
987
- value: function getActiveRoute() {
988
- var _this$routingVisualiz3;
989
- return (_this$routingVisualiz3 = this.routingVisualizer).getActiveRoute.apply(_this$routingVisualiz3, arguments);
990
- }
991
- }, {
992
- key: "highlightRouteSegment",
993
- value: function highlightRouteSegment() {
994
- var _this$routingVisualiz4;
995
- return (_this$routingVisualiz4 = this.routingVisualizer).highlightRouteSegment.apply(_this$routingVisualiz4, arguments);
996
- }
997
- }, {
998
- key: "clearRoute",
999
- value: function clearRoute() {
1000
- var _this$routingVisualiz5;
1001
- return (_this$routingVisualiz5 = this.routingVisualizer).clearRoute.apply(_this$routingVisualiz5, arguments);
1002
- }
713
+ // Check if the point is within the polygon
714
+ const isInside = (0, _booleanPointInPolygon.default)(point, polygon);
715
+ return isInside;
716
+ }
717
+ getMapObjectsByFilteredLocalRef() {
718
+ return this.metaAtlasCore.getMapObjectsByFilteredLocalRef(...arguments);
719
+ }
720
+ getMapObjectsByName() {
721
+ return this.metaAtlasCore.getMapObjectsByName(...arguments);
722
+ }
723
+ getMapObjectById() {
724
+ return this.metaAtlasCore.getMapObjectById(...arguments);
725
+ }
726
+ getMapObjectByLocalRef() {
727
+ return this.metaAtlasCore.getMapObjectByLocalRef(...arguments);
728
+ }
729
+ getMapObjectMatchingLocalRef() {
730
+ return this.metaAtlasCore.getMapObjectMatchingLocalRef(...arguments);
731
+ }
732
+ getMapObjectsMatchingLocalRefs() {
733
+ return this.metaAtlasCore.getMapObjectsMatchingLocalRefs(...arguments);
734
+ }
735
+ getMapObjectsByWhatTaxonomy() {
736
+ return this.metaAtlasCore.getMapObjectsByWhatTaxonomy(...arguments);
737
+ }
738
+ getMapObjectsByWhatTaxonomyAPI() {
739
+ return this.metaAtlasCore.getMapObjectsByWhatTaxonomyAPI(...arguments);
740
+ }
741
+ getMapObjectsByWhereTaxonomy() {
742
+ return this.metaAtlasCore.getMapObjectsByWhereTaxonomy(...arguments);
743
+ }
744
+ getMapObjectsByWhatAndWhereTaxonomy() {
745
+ return this.metaAtlasCore.getMapObjectsByWhatAndWhereTaxonomy(...arguments);
746
+ }
747
+ getMapObjectsInWhatTaxonomy() {
748
+ return this.metaAtlasCore.getMapObjectsInWhatTaxonomy(...arguments);
749
+ }
750
+ getMapObjectsInWhereTaxonomy() {
751
+ return this.metaAtlasCore.getMapObjectsInWhereTaxonomy(...arguments);
752
+ }
1003
753
 
1004
- // Drawing
1005
- }, {
1006
- key: "drawGeometryOnMap",
1007
- value: function drawGeometryOnMap(type, onDrawEnd) {
1008
- var _this8 = this;
1009
- var onlyVisibleAtCurrentFocus = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1010
- //if already in edit mode
1011
- if (this.mapBoxDraw.getMode() !== 'simple_select') return false;
1012
- var modeChanged = false;
1013
- if (type === 'draw_point') {
1014
- this.mapBoxDraw.changeMode("draw_point");
1015
- modeChanged = true;
1016
- } else if (type === 'draw_line_string') {
1017
- this.mapBoxDraw.changeMode("draw_line_string");
1018
- modeChanged = true;
1019
- } else if (type === 'draw_polygon') {
1020
- this.mapBoxDraw.changeMode("draw_polygon");
1021
- modeChanged = true;
1022
- } else if (type === 'draw_marker') {
1023
- this.mapBoxDraw.changeMode("draw_marker");
1024
- modeChanged = true;
1025
- } else console.warn("Unsupported mode passed to drawGeometryOnMap");
1026
- if (modeChanged) {
1027
- this.map.once('draw.create', function (drawings) {
1028
- var finalDrawing = drawings['features'][0];
1029
- finalDrawing.properties.id = finalDrawing.id;
1030
- if (onlyVisibleAtCurrentFocus) finalDrawing.properties.dimension_where = _this8.getCurrentFocus();else finalDrawing.properties.dimension_where = _this8.defaultFocusedTaxonomy;
1031
- onDrawEnd(finalDrawing);
754
+ // Routing
755
+ computeRoute() {
756
+ return this.routingVisualizer.computeRoute(...arguments);
757
+ }
758
+ computeRoutes(mapObjectIds) {
759
+ let wheelChairAccessibleRouteOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
760
+ let source = arguments.length > 2 ? arguments[2] : undefined;
761
+ const ref = this;
762
+ const logRouteEvent = async () => {
763
+ const getNameByIdAsync = id => {
764
+ return new Promise(resolve => {
765
+ if (typeof id !== 'string') resolve('User GPS Location');
766
+ ref.getMapObjectById(id, mapObj => {
767
+ var _mapObj$;
768
+ resolve((_mapObj$ = mapObj[0]) === null || _mapObj$ === void 0 ? void 0 : _mapObj$.name);
769
+ });
1032
770
  });
1033
- this.map.once('draw.modechange', function () {
1034
- _this8.mapBoxDraw.deleteAll();
1035
- // if (this.mapBoxDraw.getMode() === 'simple_select') onDrawEnd();
1036
- // else console.warn("Unexpected mode received in mode change callback");
771
+ };
772
+ const getNamesFromIds = async idList => {
773
+ const namePromises = idList.map(id => getNameByIdAsync(id));
774
+ return await Promise.all(namePromises);
775
+ };
776
+ const names = await getNamesFromIds(mapObjectIds);
777
+ names.forEach(name => {
778
+ this.logAnalyticsEvent('route_per_object', {
779
+ destination: name,
780
+ route_per_object_event_source: source
1037
781
  });
782
+ });
783
+ this.logAnalyticsEvent('route', {
784
+ destinations: names,
785
+ route_event_source: source
786
+ });
787
+ };
788
+ logRouteEvent();
789
+ return this.routingVisualizer.computeRoutes(mapObjectIds, wheelChairAccessibleRouteOnly);
790
+ }
791
+ setActiveRoute() {
792
+ return this.routingVisualizer.setActiveRoute(...arguments);
793
+ }
794
+ getActiveRoute() {
795
+ return this.routingVisualizer.getActiveRoute(...arguments);
796
+ }
797
+ highlightRouteSegment() {
798
+ return this.routingVisualizer.highlightRouteSegment(...arguments);
799
+ }
800
+ clearRoute() {
801
+ return this.routingVisualizer.clearRoute(...arguments);
802
+ }
803
+
804
+ // Drawing
805
+ drawGeometryOnMap(type, onDrawEnd) {
806
+ let onlyVisibleAtCurrentFocus = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
807
+ //if already in edit mode
808
+ if (this.mapBoxDraw.getMode() !== 'simple_select') return false;
809
+ let modeChanged = false;
810
+ if (type === 'draw_point') {
811
+ this.mapBoxDraw.changeMode("draw_point");
812
+ modeChanged = true;
813
+ } else if (type === 'draw_line_string') {
814
+ this.mapBoxDraw.changeMode("draw_line_string");
815
+ modeChanged = true;
816
+ } else if (type === 'draw_polygon') {
817
+ this.mapBoxDraw.changeMode("draw_polygon");
818
+ modeChanged = true;
819
+ } else if (type === 'draw_marker') {
820
+ this.mapBoxDraw.changeMode("draw_marker");
821
+ modeChanged = true;
822
+ } else console.warn("Unsupported mode passed to drawGeometryOnMap");
823
+ if (modeChanged) {
824
+ this.map.once('draw.create', drawings => {
825
+ let finalDrawing = drawings['features'][0];
826
+ finalDrawing.properties.id = finalDrawing.id;
827
+ if (onlyVisibleAtCurrentFocus) finalDrawing.properties.dimension_where = this.getCurrentFocus();else finalDrawing.properties.dimension_where = this.defaultFocusedTaxonomy;
828
+ onDrawEnd(finalDrawing);
829
+ });
830
+ this.map.once('draw.modechange', () => {
831
+ this.mapBoxDraw.deleteAll();
832
+ // if (this.mapBoxDraw.getMode() === 'simple_select') onDrawEnd();
833
+ // else console.warn("Unexpected mode received in mode change callback");
834
+ });
835
+ }
836
+ return modeChanged;
837
+ }
838
+ isInDrawMode() {
839
+ return this.mapBoxDraw && this.mapBoxDraw.getAll().features.length > 0;
840
+ }
841
+ addDrawingsToBaseMap(drawings) {
842
+ this.drawGeojsonData.features = this.drawGeojsonData.features.concat(drawings);
843
+ this.map.getSource(this.mapBoxDrawSourceID).setData(this.drawGeojsonData);
844
+ }
845
+ getDrawingById(id) {
846
+ for (let index = 0; index < this.drawGeojsonData.features.length; index++) {
847
+ const drawing = this.drawGeojsonData.features[index];
848
+ if (drawing.id === id) {
849
+ return drawing;
1038
850
  }
1039
- return modeChanged;
1040
851
  }
1041
- }, {
1042
- key: "isInDrawMode",
1043
- value: function isInDrawMode() {
1044
- return this.mapBoxDraw && this.mapBoxDraw.getAll().features.length > 0;
852
+ return undefined;
853
+ }
854
+ editDrawing(id) {
855
+ if (id === undefined) {
856
+ console.warn("maplibregl.Feature data passed to editDrawing does not contain an id. Edit request cancelled. Make sure the feature data passed in was created using draw");
857
+ return false;
1045
858
  }
1046
- }, {
1047
- key: "addDrawingsToBaseMap",
1048
- value: function addDrawingsToBaseMap(drawings) {
1049
- this.drawGeojsonData.features = this.drawGeojsonData.features.concat(drawings);
1050
- this.map.getSource(this.mapBoxDrawSourceID).setData(this.drawGeojsonData);
859
+ let drawing = this.getDrawingById(id);
860
+ if (drawing === undefined) {
861
+ console.warn("There is no data against the id passed in to editDrawing, operation cancelled.");
862
+ return false;
1051
863
  }
1052
- }, {
1053
- key: "getDrawingById",
1054
- value: function getDrawingById(id) {
1055
- for (var index = 0; index < this.drawGeojsonData.features.length; index++) {
1056
- var drawing = this.drawGeojsonData.features[index];
1057
- if (drawing.id === id) {
1058
- return drawing;
864
+ let featureCollection = {
865
+ type: 'FeatureCollection',
866
+ features: [drawing]
867
+ };
868
+ //console.log(featureCollection)
869
+ this.mapBoxDraw.set(featureCollection);
870
+ const saveEditsToBaseMap = featureId => {
871
+ const updatedFeature = this.mapBoxDraw.get(featureId);
872
+ this.mapBoxDraw.deleteAll();
873
+ if (updatedFeature) {
874
+ let featureFoundInBaseMapData = false;
875
+ for (let index = 0; index < this.drawGeojsonData.features.length; index++) {
876
+ const feature = this.drawGeojsonData.features[index];
877
+ if (feature.id === updatedFeature.id) {
878
+ this.drawGeojsonData.features[index] = updatedFeature;
879
+ featureFoundInBaseMapData = true;
880
+ }
1059
881
  }
882
+ if (featureFoundInBaseMapData) this.map.getSource(this.mapBoxDrawSourceID).setData(this.drawGeojsonData);else console.warn("Edited feature data not found in base map. Make sure addFeaturesToBaseMap was called on feature data before editing.");
1060
883
  }
1061
- return undefined;
1062
- }
1063
- }, {
1064
- key: "editDrawing",
1065
- value: function editDrawing(id) {
1066
- var _this9 = this;
1067
- if (id === undefined) {
1068
- console.warn("maplibregl.Feature data passed to editDrawing does not contain an id. Edit request cancelled. Make sure the feature data passed in was created using draw");
1069
- return false;
1070
- }
1071
- var drawing = this.getDrawingById(id);
1072
- if (drawing === undefined) {
1073
- console.warn("There is no data against the id passed in to editDrawing, operation cancelled.");
1074
- return false;
884
+ };
885
+ if (drawing.geometry.type !== 'Point') {
886
+ if (drawing.properties.marker !== undefined) {
887
+ this.mapBoxDraw.changeMode('marker_select', {
888
+ featureId: drawing.id
889
+ });
890
+ } else {
891
+ this.mapBoxDraw.changeMode('direct_select', {
892
+ featureId: drawing.id
893
+ });
1075
894
  }
1076
- var featureCollection = {
1077
- type: 'FeatureCollection',
1078
- features: [drawing]
1079
- };
1080
- //console.log(featureCollection)
1081
- this.mapBoxDraw.set(featureCollection);
1082
- var saveEditsToBaseMap = function saveEditsToBaseMap(featureId) {
1083
- var updatedFeature = _this9.mapBoxDraw.get(featureId);
1084
- _this9.mapBoxDraw.deleteAll();
1085
- if (updatedFeature) {
1086
- var featureFoundInBaseMapData = false;
1087
- for (var index = 0; index < _this9.drawGeojsonData.features.length; index++) {
1088
- var feature = _this9.drawGeojsonData.features[index];
1089
- if (feature.id === updatedFeature.id) {
1090
- _this9.drawGeojsonData.features[index] = updatedFeature;
1091
- featureFoundInBaseMapData = true;
1092
- }
895
+ this.map.once('draw.modechange', () => {
896
+ if (this.mapBoxDraw.getMode() !== 'simple_select') return;
897
+ saveEditsToBaseMap(drawing.id);
898
+ });
899
+ } else {
900
+ let featureToEditSelectedAlready = false;
901
+ const onSelectionChanged = selectionData => {
902
+ //console.log(selectionData, drawing)
903
+ if (selectionData.features.length > 0 && selectionData.features[0].id === drawing.id) {
904
+ if (!featureToEditSelectedAlready) {
905
+ featureToEditSelectedAlready = true;
1093
906
  }
1094
- if (featureFoundInBaseMapData) _this9.map.getSource(_this9.mapBoxDrawSourceID).setData(_this9.drawGeojsonData);else console.warn("Edited feature data not found in base map. Make sure addFeaturesToBaseMap was called on feature data before editing.");
907
+ } else if (featureToEditSelectedAlready) {
908
+ saveEditsToBaseMap(drawing.id);
909
+ this.map.off('draw.selectionchange', onSelectionChanged);
1095
910
  }
1096
911
  };
1097
- if (drawing.geometry.type !== 'Point') {
1098
- if (drawing.properties.marker !== undefined) {
1099
- this.mapBoxDraw.changeMode('marker_select', {
1100
- featureId: drawing.id
1101
- });
1102
- } else {
1103
- this.mapBoxDraw.changeMode('direct_select', {
1104
- featureId: drawing.id
1105
- });
1106
- }
1107
- this.map.once('draw.modechange', function () {
1108
- if (_this9.mapBoxDraw.getMode() !== 'simple_select') return;
1109
- saveEditsToBaseMap(drawing.id);
1110
- });
1111
- } else {
1112
- var featureToEditSelectedAlready = false;
1113
- var _onSelectionChanged = function onSelectionChanged(selectionData) {
1114
- //console.log(selectionData, drawing)
1115
- if (selectionData.features.length > 0 && selectionData.features[0].id === drawing.id) {
1116
- if (!featureToEditSelectedAlready) {
1117
- featureToEditSelectedAlready = true;
1118
- }
1119
- } else if (featureToEditSelectedAlready) {
1120
- saveEditsToBaseMap(drawing.id);
1121
- _this9.map.off('draw.selectionchange', _onSelectionChanged);
1122
- }
1123
- };
1124
- this.map.on('draw.selectionchange', _onSelectionChanged);
1125
- }
1126
- return true;
912
+ this.map.on('draw.selectionchange', onSelectionChanged);
1127
913
  }
1128
- }, {
1129
- key: "removeDrawing",
1130
- value: function removeDrawing(id) {
1131
- for (var index = 0; index < this.drawGeojsonData.features.length; index++) {
1132
- var drawing = this.drawGeojsonData.features[index];
1133
- if (drawing.id === id) {
1134
- this.drawGeojsonData.features.splice(index, 1);
1135
- this.map.getSource(this.mapBoxDrawSourceID).setData(this.drawGeojsonData);
1136
- return true;
1137
- }
914
+ return true;
915
+ }
916
+ removeDrawing(id) {
917
+ for (let index = 0; index < this.drawGeojsonData.features.length; index++) {
918
+ const drawing = this.drawGeojsonData.features[index];
919
+ if (drawing.id === id) {
920
+ this.drawGeojsonData.features.splice(index, 1);
921
+ this.map.getSource(this.mapBoxDrawSourceID).setData(this.drawGeojsonData);
922
+ return true;
1138
923
  }
1139
- return false;
1140
924
  }
1141
- }, {
1142
- key: "createMarker",
1143
- value: function createMarker(options) {
1144
- if (options === undefined) options = {};
1145
- options.draggable = true;
1146
- options.color = '#FFB52E';
1147
- var marker = new maplibregl.Marker(options).setLngLat(this.map.getCenter()).addTo(this.map);
1148
- this.map.once('click', function () {
1149
- marker.setDraggable(false);
925
+ return false;
926
+ }
927
+ createMarker(options) {
928
+ if (options === undefined) options = {};
929
+ options.draggable = true;
930
+ options.color = '#FFB52E';
931
+ const marker = new maplibregl.Marker(options).setLngLat(this.map.getCenter()).addTo(this.map);
932
+ this.map.once('click', () => {
933
+ marker.setDraggable(false);
1150
934
 
1151
- // update color
1152
- var color = '#3FB1CE';
1153
- var markerElement = marker.getElement();
1154
- markerElement.querySelectorAll('svg g[fill="' + marker._color + '"]')[0].setAttribute("fill", color);
1155
- marker._color = color;
1156
- });
1157
- return marker;
1158
- }
1159
- }, {
1160
- key: "getCoordinates",
1161
- value: function getCoordinates(feature) {
1162
- return (0, _invariant.getCoords)(feature);
1163
- }
1164
- }, {
1165
- key: "getLength",
1166
- value: function getLength(feature) {
1167
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1168
- units: 'kilometers'
1169
- };
1170
- if (feature.geometry && feature.geometry.type) {
1171
- var type = feature.geometry.type;
1172
- if (type === 'LineString' || type === 'MultiLineString') {
1173
- return (0, _length["default"])(feature, options);
1174
- }
1175
- }
1176
- console.warn("Unsupported geometry type provided to getLength");
1177
- return undefined;
1178
- }
1179
- }, {
1180
- key: "getArea",
1181
- value: function getArea(feature) {
1182
- return (0, _area["default"])(feature);
1183
- }
935
+ // update color
936
+ const color = '#3FB1CE';
937
+ let markerElement = marker.getElement();
938
+ markerElement.querySelectorAll('svg g[fill="' + marker._color + '"]')[0].setAttribute("fill", color);
939
+ marker._color = color;
940
+ });
941
+ return marker;
942
+ }
943
+ getCoordinates(feature) {
944
+ return (0, _invariant.getCoords)(feature);
945
+ }
946
+ getLength(feature) {
947
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
948
+ units: 'kilometers'
949
+ };
950
+ if (feature.geometry && feature.geometry.type) {
951
+ const type = feature.geometry.type;
952
+ if (type === 'LineString' || type === 'MultiLineString') {
953
+ return (0, _length.default)(feature, options);
954
+ }
955
+ }
956
+ console.warn("Unsupported geometry type provided to getLength");
957
+ return undefined;
958
+ }
959
+ getArea(feature) {
960
+ return (0, _area.default)(feature);
961
+ }
1184
962
 
1185
- /**
1186
- * Get the 3D map instance for 3D model operations
1187
- */
1188
- }, {
1189
- key: "getMap3D",
1190
- value: function getMap3D() {
1191
- return this.map3D;
1192
- }
1193
- }]);
1194
- }();
963
+ /**
964
+ * Get the 3D map instance for 3D model operations
965
+ */
966
+ getMap3D() {
967
+ return this.map3D;
968
+ }
969
+ }
970
+ exports.MetaAtlasSdk = MetaAtlasSdk;
1195
971
  //# sourceMappingURL=meta-atlas-sdk.js.map