waygo-maps 1.0.69 → 1.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +3 -3
- package/dist/style.css +2 -2
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -592,7 +592,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
592
592
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
593
593
|
|
|
594
594
|
"use strict";
|
|
595
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _core_Control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../core/Control */ \"./src/core/Control.js\");\n/* harmony import */ var _components_DirectionsView_DirectionsView__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../components/DirectionsView/DirectionsView */ \"./src/components/DirectionsView/DirectionsView.js\");\n/* harmony import */ var _WaygoMaps__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../WaygoMaps */ \"./src/WaygoMaps.js\");\n/* harmony import */ var _components_DirectionsView_StepsView__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../components/DirectionsView/StepsView */ \"./src/components/DirectionsView/StepsView.js\");\n/* harmony import */ var _utils_coordinateSystems__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/coordinateSystems */ \"./src/utils/coordinateSystems.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! axios */ \"./node_modules/axios/lib/axios.js\");\nfunction _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); }\nfunction _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; }\nfunction _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _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; } }\nfunction _iterableToArray(r) { if (\"undefined\" != typeof Symbol && null != r[Symbol.iterator] || null != r[\"@@iterator\"]) return Array.from(r); }\nfunction _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }\nfunction _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; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction 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); }\nfunction _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); }); }; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _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); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _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); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _superPropGet(t, e, r, o) { var p = _get(_getPrototypeOf(1 & o ? t.prototype : t), e, r); return 2 & o ? function (t) { return p.apply(r, t); } : p; }\nfunction _get() { return _get = \"undefined\" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }\nfunction _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\n\n\n\n\n\n\nvar DirectionsControl = /*#__PURE__*/function (_Control) {\n function DirectionsControl() {\n var _this;\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _classCallCheck(this, DirectionsControl);\n _this = _callSuper(this, DirectionsControl, [options]);\n _this.directionsView = null;\n _this.stepsView = null;\n _this.map = null;\n _this.searchApi = _WaygoMaps__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getSearchApi();\n _this.startContentPlacement = null;\n _this.endContentPlacement = null;\n return _this;\n }\n _inherits(DirectionsControl, _Control);\n return _createClass(DirectionsControl, [{\n key: \"onAdd\",\n value: function onAdd(map) {\n this.map = map;\n this.container = document.createElement('div');\n this.container.className = 'directions-control-container';\n this.directionsView = new _components_DirectionsView_DirectionsView__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n this.stepsView = new _components_DirectionsView_StepsView__WEBPACK_IMPORTED_MODULE_3__[\"default\"]();\n this.container.appendChild(this.directionsView.getElement());\n this.initializeEventListeners();\n this.createDirectionsLineLayer();\n this._attachResizeListener();\n this._initialize();\n this.hide();\n return this.container;\n }\n }, {\n key: \"onRemove\",\n value: function onRemove() {\n _superPropGet(DirectionsControl, \"onRemove\", this, 3)([]);\n }\n }, {\n key: \"initializeEventListeners\",\n value: function initializeEventListeners() {\n this.map.on('state:default', this._handleDefaultState.bind(this));\n this.map.on('state:search', this._handleSearchState.bind(this));\n this.map.on('state:selectedContent', this._handleSelectedContentState.bind(this));\n this.map.on('state:directions', this._handleDirectionsState.bind(this));\n // this.map.on('initiate:back', this._handleMapInitiateBack.bind(this));\n\n this.directionsView.on('getStartSuggestions', this._handleGettingStartSearchBarSuggestions.bind(this));\n this.directionsView.on('getEndSuggestions', this._handleGettingEndSearchBarSuggestions.bind(this));\n this.directionsView.on('initiate:findPath', this._handleIntiateFindPath.bind(this));\n // this.directionsView.on('initiate:changeLeg', this._handleLegChange.bind(this));\n this.directionsView.on('selectedStartContentPlacement', this._handleStartContentPlacementSelected.bind(this));\n this.directionsView.on('selectedEndContentPlacement', this._handleEndContentPlacementSelected.bind(this));\n this.stepsView.on('legSelect', this._handleLegChange.bind(this));\n }\n }, {\n key: \"_handleEndContentPlacementSelected\",\n value: function _handleEndContentPlacementSelected(data) {\n var endContentPlacement = data.endContentPlacement;\n this.endContentPlacement = endContentPlacement;\n var _convertVertexToCoord = (0,_utils_coordinateSystems__WEBPACK_IMPORTED_MODULE_4__.convertVertexToCoordinate)(endContentPlacement.location, null, 30.0),\n lat = _convertVertexToCoord.lat,\n lon = _convertVertexToCoord.lon;\n var coordinate = [lon, lat];\n if (!endContentPlacement.name) {\n if (endContentPlacement.content) {\n if (endContentPlacement.content.title_key) {\n var titleKey = endContentPlacement.content.title_key;\n var title = endContentPlacement.content.data[titleKey];\n endContentPlacement.name = title;\n }\n }\n }\n endContentPlacement._floor = endContentPlacement.floor;\n this.map.addSelectedFeature(coordinate, endContentPlacement);\n }\n }, {\n key: \"_handleStartContentPlacementSelected\",\n value: function _handleStartContentPlacementSelected(data) {\n var startContentPlacement = data.startContentPlacement;\n this.startContentPlacement = startContentPlacement;\n var _convertVertexToCoord2 = (0,_utils_coordinateSystems__WEBPACK_IMPORTED_MODULE_4__.convertVertexToCoordinate)(startContentPlacement.location, null, 30.0),\n lat = _convertVertexToCoord2.lat,\n lon = _convertVertexToCoord2.lon;\n var coordinate = [lon, lat];\n if (!startContentPlacement.name) {\n if (startContentPlacement.content) {\n if (startContentPlacement.content.title_key) {\n var titleKey = startContentPlacement.content.title_key;\n var title = startContentPlacement.content.data[titleKey];\n startContentPlacement.name = title;\n }\n }\n }\n startContentPlacement._floor = startContentPlacement.floor;\n this.map.clearHighlightedContentLayer();\n this.map.addHighlightedFeature(coordinate, startContentPlacement);\n }\n }, {\n key: \"_handleLegChange\",\n value: function _handleLegChange(data) {\n var index = data.index;\n if (!this.directionsView || !this.pathData) {\n return;\n }\n this.updateMapForPathLeg(this.pathData.legs[index]);\n }\n }, {\n key: \"_handleGettingStartSearchBarSuggestions\",\n value: function () {\n var _handleGettingStartSearchBarSuggestions2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {\n var query, currentSearch, skip, limit, results;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n if (this.directionsView) {\n _context.next = 2;\n break;\n }\n return _context.abrupt(\"return\");\n case 2:\n query = data.query;\n currentSearch = ++this.directionsView.startSearchBox.searchCount;\n if (!(query === '')) {\n _context.next = 7;\n break;\n }\n this.directionsView.startSearchBox.searchBarSuggestionsView.updateResults([]);\n return _context.abrupt(\"return\");\n case 7:\n if (this.map.mapData) {\n _context.next = 9;\n break;\n }\n return _context.abrupt(\"return\");\n case 9:\n skip = 0;\n limit = 5;\n _context.prev = 11;\n _context.next = 14;\n return this.searchApi.search(this.map.mapData.map_id, this.map.mapData.map_view_id, query, skip, limit);\n case 14:\n results = _context.sent;\n if (currentSearch === this.directionsView.startSearchBox.searchCount) {\n this.directionsView.startSearchBox.searchBarSuggestionsView.updateResults(results);\n }\n _context.next = 21;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](11);\n if (axios__WEBPACK_IMPORTED_MODULE_5__[\"default\"].isCancel(_context.t0)) {\n console.error('Request canceled:', _context.t0.message);\n } else {\n console.error('Search error:', _context.t0);\n }\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[11, 18]]);\n }));\n function _handleGettingStartSearchBarSuggestions(_x) {\n return _handleGettingStartSearchBarSuggestions2.apply(this, arguments);\n }\n return _handleGettingStartSearchBarSuggestions;\n }()\n }, {\n key: \"_handleGettingEndSearchBarSuggestions\",\n value: function () {\n var _handleGettingEndSearchBarSuggestions2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) {\n var query, currentSearch, skip, limit, results;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (this.directionsView) {\n _context2.next = 2;\n break;\n }\n return _context2.abrupt(\"return\");\n case 2:\n query = data.query;\n currentSearch = ++this.directionsView.endSearchBox.searchCount;\n if (!(query === '')) {\n _context2.next = 7;\n break;\n }\n this.directionsView.endSearchBox.searchBarSuggestionsView.updateResults([]);\n return _context2.abrupt(\"return\");\n case 7:\n if (this.map.mapData) {\n _context2.next = 9;\n break;\n }\n return _context2.abrupt(\"return\");\n case 9:\n skip = 0;\n limit = 5;\n _context2.prev = 11;\n _context2.next = 14;\n return this.searchApi.search(this.map.mapData.map_id, this.map.mapData.map_view_id, query, skip, limit);\n case 14:\n results = _context2.sent;\n if (currentSearch === this.directionsView.endSearchBox.searchCount) {\n this.directionsView.endSearchBox.searchBarSuggestionsView.updateResults(results);\n }\n _context2.next = 21;\n break;\n case 18:\n _context2.prev = 18;\n _context2.t0 = _context2[\"catch\"](11);\n if (axios__WEBPACK_IMPORTED_MODULE_5__[\"default\"].isCancel(_context2.t0)) {\n console.error('Request canceled:', _context2.t0.message);\n } else {\n console.error('Search error:', _context2.t0);\n }\n case 21:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[11, 18]]);\n }));\n function _handleGettingEndSearchBarSuggestions(_x2) {\n return _handleGettingEndSearchBarSuggestions2.apply(this, arguments);\n }\n return _handleGettingEndSearchBarSuggestions;\n }()\n }, {\n key: \"_renderDesktopView\",\n value: function _renderDesktopView() {\n if (!this.directionsView) {\n return;\n }\n var element = this.directionsView.getElement();\n this.container.appendChild(element);\n this.container.classList.remove('mobile-view');\n this.container.classList.add('desktop-view');\n this.container.appendChild(this.stepsView.getElement());\n // if (this.pathData) {\n // this.element.appendChild(this.stepsView.getElement());\n // }\n }\n }, {\n key: \"_renderMobileView\",\n value: function _renderMobileView() {\n if (!this.directionsView) {\n return;\n }\n var element = this.directionsView.getElement();\n this.container.appendChild(element);\n this.container.classList.remove('desktop-view');\n this.container.classList.add('mobile-view');\n this.container.appendChild(this.stepsView.getElement());\n // this.element.appendChild(this.stepsView.getElement());\n // }\n }\n }, {\n key: \"createDirectionsLineLayer\",\n value: function createDirectionsLineLayer() {\n this.map.map.addSource('directionsLineSource', {\n 'type': 'geojson',\n 'data': {\n 'type': 'Feature',\n 'properties': {},\n 'geometry': {\n 'type': 'LineString',\n 'coordinates': []\n }\n }\n });\n\n // Add a new layer for the line\n this.map.map.addLayer({\n 'id': 'directionsLineLayer',\n 'type': 'line',\n 'source': 'directionsLineSource',\n 'layout': {\n 'line-join': 'round',\n 'line-cap': 'round'\n },\n 'paint': {\n 'line-color': '#333333',\n 'line-width': 8\n // 'line-blur': 0.9\n }\n });\n\n // this.map.map.moveLayer('directionsLineLayer', 'off-limits');\n // this.map.map.moveLayer('directionsLineLayer', '0-tertiary-area');\n this.map.map.moveLayer('directionsLineLayer', 'FIRST_ELEVATED_FEATURE');\n }\n }, {\n key: \"updateMapForPathLeg\",\n value: function updateMapForPathLeg(leg) {\n this.clearLineData();\n var points = [];\n leg.steps.forEach(function (step, index) {\n if (index === 0) {\n points.push.apply(points, _toConsumableArray(step.path));\n } else {\n points.push(step.path[1]);\n }\n });\n var coordinates = (0,_utils_coordinateSystems__WEBPACK_IMPORTED_MODULE_4__.convertVerticesToCoordinates)(points, null, 30.0);\n console.log(coordinates);\n this._updateMapLineData(coordinates, leg.floor);\n var currentFloor = this.map.getCurrentFloor();\n if (currentFloor !== leg.floor) {\n this.map.updateFloor(leg.floor, false);\n }\n }\n }, {\n key: \"_updateMapLineData\",\n value: function _updateMapLineData(newCoordinates, floor) {\n this.map.map.getSource('directionsLineSource').setData({\n 'type': 'Feature',\n 'properties': {\n '_floor': floor\n },\n 'geometry': {\n 'type': 'LineString',\n 'coordinates': newCoordinates\n }\n });\n var bounds = new mapboxgl.LngLatBounds();\n newCoordinates.forEach(function (coordinate) {\n bounds.extend(coordinate);\n });\n this.map.map.fitBounds(bounds, _defineProperty(_defineProperty(_defineProperty({\n padding: 200\n }, \"padding\", {\n top: 200,\n bottom: 200,\n left: 500,\n right: 150\n }), \"maxZoom\", 16), \"duration\", 1000));\n }\n }, {\n key: \"clearLineData\",\n value: function clearLineData() {\n this.map.map.getSource('directionsLineSource').setData({\n 'type': 'Feature',\n 'properties': {},\n 'geometry': {\n 'type': 'LineString',\n 'coordinates': []\n }\n });\n }\n }, {\n key: \"_handleDefaultState\",\n value: function _handleDefaultState() {\n this.hide();\n this.clearLineData();\n }\n }, {\n key: \"_handleSearchState\",\n value: function _handleSearchState(data) {\n var query = data.query,\n results = data.results;\n this.hide();\n this.clearLineData();\n }\n }, {\n key: \"_handleSelectedContentState\",\n value: function _handleSelectedContentState(data) {\n var contentPlacementIds = data.contentPlacementIds,\n selectedContentPlacement = data.selectedContentPlacement;\n this.hide();\n this.directionsView.updateView(null, null);\n this.clearLineData();\n // this.map.clearSelectedContentLayer();\n this.map.clearHighlightedContentLayer();\n }\n }, {\n key: \"_handleDirectionsState\",\n value: function _handleDirectionsState(data) {\n var startContentPlacement = data.startContentPlacement,\n endContentPlacement = data.endContentPlacement;\n this.show();\n this.clearLineData();\n this.directionsView.updateView(startContentPlacement, endContentPlacement);\n if (endContentPlacement) {\n var _convertVertexToCoord3 = (0,_utils_coordinateSystems__WEBPACK_IMPORTED_MODULE_4__.convertVertexToCoordinate)(endContentPlacement.location, null, 30.0),\n lat = _convertVertexToCoord3.lat,\n lon = _convertVertexToCoord3.lon;\n var coordinate = [lon, lat];\n if (!endContentPlacement.name) {\n if (endContentPlacement.content) {\n if (endContentPlacement.content.title_key) {\n var titleKey = endContentPlacement.content.title_key;\n var title = endContentPlacement.content.data[titleKey];\n endContentPlacement.name = title;\n }\n }\n }\n endContentPlacement._floor = endContentPlacement.floor;\n this.map.addSelectedFeature(coordinate, endContentPlacement);\n }\n }\n }, {\n key: \"_handleIntiateFindPath\",\n value: function () {\n var _handleIntiateFindPath2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(data) {\n var startContentPlacementId, endContentPlacementId;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n startContentPlacementId = data.startContentPlacementId, endContentPlacementId = data.endContentPlacementId;\n _context3.next = 3;\n return this.map.findPath(startContentPlacementId, endContentPlacementId);\n case 3:\n this.pathData = _context3.sent;\n this.directionsView.setNewPath(this.pathData);\n this.stepsView.setNewPath(this.pathData);\n this.updateMapForPathLeg(this.pathData.legs[0]);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n function _handleIntiateFindPath(_x3) {\n return _handleIntiateFindPath2.apply(this, arguments);\n }\n return _handleIntiateFindPath;\n }()\n }, {\n key: \"_handleSelectDirectionsButton\",\n value: function _handleSelectDirectionsButton(data) {\n var placementId = data.placementId;\n }\n }, {\n key: \"_render\",\n value: function _render() {\n return;\n }\n }]);\n}(_core_Control__WEBPACK_IMPORTED_MODULE_0__[\"default\"]);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DirectionsControl);\n\n//# sourceURL=webpack://waygomaps/./src/Controls/DirectionsControl.js?");
|
|
595
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _core_Control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../core/Control */ \"./src/core/Control.js\");\n/* harmony import */ var _components_DirectionsView_DirectionsView__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../components/DirectionsView/DirectionsView */ \"./src/components/DirectionsView/DirectionsView.js\");\n/* harmony import */ var _WaygoMaps__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../WaygoMaps */ \"./src/WaygoMaps.js\");\n/* harmony import */ var _components_DirectionsView_StepsView__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../components/DirectionsView/StepsView */ \"./src/components/DirectionsView/StepsView.js\");\n/* harmony import */ var _utils_coordinateSystems__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/coordinateSystems */ \"./src/utils/coordinateSystems.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! axios */ \"./node_modules/axios/lib/axios.js\");\nfunction _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); }\nfunction _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; }\nfunction _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _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; } }\nfunction _iterableToArray(r) { if (\"undefined\" != typeof Symbol && null != r[Symbol.iterator] || null != r[\"@@iterator\"]) return Array.from(r); }\nfunction _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }\nfunction _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; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction 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); }\nfunction _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); }); }; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _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); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _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); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _superPropGet(t, e, r, o) { var p = _get(_getPrototypeOf(1 & o ? t.prototype : t), e, r); return 2 & o ? function (t) { return p.apply(r, t); } : p; }\nfunction _get() { return _get = \"undefined\" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }\nfunction _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\n\n\n\n\n\n\nvar DirectionsControl = /*#__PURE__*/function (_Control) {\n function DirectionsControl() {\n var _this;\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _classCallCheck(this, DirectionsControl);\n _this = _callSuper(this, DirectionsControl, [options]);\n _this.directionsView = null;\n _this.stepsView = null;\n _this.map = null;\n _this.searchApi = _WaygoMaps__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getSearchApi();\n _this.startContentPlacement = null;\n _this.endContentPlacement = null;\n return _this;\n }\n _inherits(DirectionsControl, _Control);\n return _createClass(DirectionsControl, [{\n key: \"onAdd\",\n value: function onAdd(map) {\n this.map = map;\n this.container = document.createElement('div');\n this.container.className = 'directions-control-container';\n this.directionsView = new _components_DirectionsView_DirectionsView__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n this.stepsView = new _components_DirectionsView_StepsView__WEBPACK_IMPORTED_MODULE_3__[\"default\"]();\n this.container.appendChild(this.directionsView.getElement());\n this.initializeEventListeners();\n this.createDirectionsLineLayer();\n this._attachResizeListener();\n this._initialize();\n this.hide();\n return this.container;\n }\n }, {\n key: \"onRemove\",\n value: function onRemove() {\n _superPropGet(DirectionsControl, \"onRemove\", this, 3)([]);\n }\n }, {\n key: \"initializeEventListeners\",\n value: function initializeEventListeners() {\n this.map.on('state:default', this._handleDefaultState.bind(this));\n this.map.on('state:search', this._handleSearchState.bind(this));\n this.map.on('state:selectedContent', this._handleSelectedContentState.bind(this));\n this.map.on('state:directions', this._handleDirectionsState.bind(this));\n // this.map.on('initiate:back', this._handleMapInitiateBack.bind(this));\n\n this.directionsView.on('getStartSuggestions', this._handleGettingStartSearchBarSuggestions.bind(this));\n this.directionsView.on('getEndSuggestions', this._handleGettingEndSearchBarSuggestions.bind(this));\n this.directionsView.on('initiate:findPath', this._handleIntiateFindPath.bind(this));\n // this.directionsView.on('initiate:changeLeg', this._handleLegChange.bind(this));\n this.directionsView.on('selectedStartContentPlacement', this._handleStartContentPlacementSelected.bind(this));\n this.directionsView.on('selectedEndContentPlacement', this._handleEndContentPlacementSelected.bind(this));\n this.stepsView.on('legSelect', this._handleLegChange.bind(this));\n }\n }, {\n key: \"_handleEndContentPlacementSelected\",\n value: function _handleEndContentPlacementSelected(data) {\n var endContentPlacement = data.endContentPlacement;\n this.endContentPlacement = endContentPlacement;\n var _convertVertexToCoord = (0,_utils_coordinateSystems__WEBPACK_IMPORTED_MODULE_4__.convertVertexToCoordinate)(endContentPlacement.location, null, 30.0),\n lat = _convertVertexToCoord.lat,\n lon = _convertVertexToCoord.lon;\n var coordinate = [lon, lat];\n if (!endContentPlacement.name) {\n if (endContentPlacement.content) {\n if (endContentPlacement.content.title_key) {\n var titleKey = endContentPlacement.content.title_key;\n var title = endContentPlacement.content.data[titleKey];\n endContentPlacement.name = title;\n }\n }\n }\n endContentPlacement._floor = endContentPlacement.floor;\n this.map.addSelectedFeature(coordinate, endContentPlacement);\n }\n }, {\n key: \"_handleStartContentPlacementSelected\",\n value: function _handleStartContentPlacementSelected(data) {\n var startContentPlacement = data.startContentPlacement;\n this.startContentPlacement = startContentPlacement;\n var _convertVertexToCoord2 = (0,_utils_coordinateSystems__WEBPACK_IMPORTED_MODULE_4__.convertVertexToCoordinate)(startContentPlacement.location, null, 30.0),\n lat = _convertVertexToCoord2.lat,\n lon = _convertVertexToCoord2.lon;\n var coordinate = [lon, lat];\n if (!startContentPlacement.name) {\n if (startContentPlacement.content) {\n if (startContentPlacement.content.title_key) {\n var titleKey = startContentPlacement.content.title_key;\n var title = startContentPlacement.content.data[titleKey];\n startContentPlacement.name = title;\n }\n }\n }\n startContentPlacement._floor = startContentPlacement.floor;\n this.map.clearHighlightedContentLayer();\n this.map.addHighlightedFeature(coordinate, startContentPlacement);\n }\n }, {\n key: \"_handleLegChange\",\n value: function _handleLegChange(data) {\n var index = data.index;\n if (!this.directionsView || !this.pathData) {\n return;\n }\n this.updateMapForPathLeg(this.pathData.legs[index]);\n }\n }, {\n key: \"_handleGettingStartSearchBarSuggestions\",\n value: function () {\n var _handleGettingStartSearchBarSuggestions2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {\n var query, currentSearch, skip, limit, results;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n if (this.directionsView) {\n _context.next = 2;\n break;\n }\n return _context.abrupt(\"return\");\n case 2:\n query = data.query;\n currentSearch = ++this.directionsView.startSearchBox.searchCount;\n if (!(query === '')) {\n _context.next = 7;\n break;\n }\n this.directionsView.startSearchBox.searchBarSuggestionsView.updateResults([]);\n return _context.abrupt(\"return\");\n case 7:\n if (this.map.mapData) {\n _context.next = 9;\n break;\n }\n return _context.abrupt(\"return\");\n case 9:\n skip = 0;\n limit = 5;\n _context.prev = 11;\n _context.next = 14;\n return this.searchApi.search(this.map.mapData.map_id, this.map.mapData.map_view_id, query, skip, limit);\n case 14:\n results = _context.sent;\n if (currentSearch === this.directionsView.startSearchBox.searchCount) {\n this.directionsView.startSearchBox.searchBarSuggestionsView.updateResults(results);\n }\n _context.next = 21;\n break;\n case 18:\n _context.prev = 18;\n _context.t0 = _context[\"catch\"](11);\n if (axios__WEBPACK_IMPORTED_MODULE_5__[\"default\"].isCancel(_context.t0)) {\n console.error('Request canceled:', _context.t0.message);\n } else {\n console.error('Search error:', _context.t0);\n }\n case 21:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[11, 18]]);\n }));\n function _handleGettingStartSearchBarSuggestions(_x) {\n return _handleGettingStartSearchBarSuggestions2.apply(this, arguments);\n }\n return _handleGettingStartSearchBarSuggestions;\n }()\n }, {\n key: \"_handleGettingEndSearchBarSuggestions\",\n value: function () {\n var _handleGettingEndSearchBarSuggestions2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) {\n var query, currentSearch, skip, limit, results;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n if (this.directionsView) {\n _context2.next = 2;\n break;\n }\n return _context2.abrupt(\"return\");\n case 2:\n query = data.query;\n currentSearch = ++this.directionsView.endSearchBox.searchCount;\n if (!(query === '')) {\n _context2.next = 7;\n break;\n }\n this.directionsView.endSearchBox.searchBarSuggestionsView.updateResults([]);\n return _context2.abrupt(\"return\");\n case 7:\n if (this.map.mapData) {\n _context2.next = 9;\n break;\n }\n return _context2.abrupt(\"return\");\n case 9:\n skip = 0;\n limit = 5;\n _context2.prev = 11;\n _context2.next = 14;\n return this.searchApi.search(this.map.mapData.map_id, this.map.mapData.map_view_id, query, skip, limit);\n case 14:\n results = _context2.sent;\n if (currentSearch === this.directionsView.endSearchBox.searchCount) {\n this.directionsView.endSearchBox.searchBarSuggestionsView.updateResults(results);\n }\n _context2.next = 21;\n break;\n case 18:\n _context2.prev = 18;\n _context2.t0 = _context2[\"catch\"](11);\n if (axios__WEBPACK_IMPORTED_MODULE_5__[\"default\"].isCancel(_context2.t0)) {\n console.error('Request canceled:', _context2.t0.message);\n } else {\n console.error('Search error:', _context2.t0);\n }\n case 21:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this, [[11, 18]]);\n }));\n function _handleGettingEndSearchBarSuggestions(_x2) {\n return _handleGettingEndSearchBarSuggestions2.apply(this, arguments);\n }\n return _handleGettingEndSearchBarSuggestions;\n }()\n }, {\n key: \"_renderDesktopView\",\n value: function _renderDesktopView() {\n if (!this.directionsView) {\n return;\n }\n var element = this.directionsView.getElement();\n this.container.appendChild(element);\n this.container.classList.remove('mobile-view');\n this.container.classList.add('desktop-view');\n this.container.appendChild(this.stepsView.getElement());\n // if (this.pathData) {\n // this.element.appendChild(this.stepsView.getElement());\n // }\n }\n }, {\n key: \"_renderMobileView\",\n value: function _renderMobileView() {\n if (!this.directionsView) {\n return;\n }\n var element = this.directionsView.getElement();\n this.container.appendChild(element);\n this.container.classList.remove('desktop-view');\n this.container.classList.add('mobile-view');\n this.container.appendChild(this.stepsView.getElement());\n // this.element.appendChild(this.stepsView.getElement());\n // }\n }\n }, {\n key: \"createDirectionsLineLayer\",\n value: function createDirectionsLineLayer() {\n this.map.map.addSource('directionsLineSource', {\n 'type': 'geojson',\n 'data': {\n 'type': 'Feature',\n 'properties': {},\n 'geometry': {\n 'type': 'LineString',\n 'coordinates': []\n }\n }\n });\n\n // Add a new layer for the line\n this.map.map.addLayer({\n 'id': 'directionsLineLayer',\n 'type': 'line',\n 'source': 'directionsLineSource',\n 'layout': {\n 'line-join': 'round',\n 'line-cap': 'round'\n },\n 'paint': {\n 'line-color': '#333333',\n 'line-width': 8\n // 'line-blur': 0.9\n }\n });\n\n // this.map.map.moveLayer('directionsLineLayer', 'off-limits');\n // this.map.map.moveLayer('directionsLineLayer', '0-tertiary-area');\n this.map.map.moveLayer('directionsLineLayer', 'FIRST_ELEVATED_FEATURE');\n }\n }, {\n key: \"updateMapForPathLeg\",\n value: function updateMapForPathLeg(leg) {\n this.clearLineData();\n var points = [];\n leg.steps.forEach(function (step, index) {\n points.push.apply(points, _toConsumableArray(index === 0 ? step.path : step.path.slice(1)));\n // console.log(`Step ${index} path: ${leg.steps.length}`);\n // if (index === 0) {\n // points.push(...step.path);\n // } else {\n // points.push(step.path[1]);\n // }\n });\n\n // else if (index === leg.steps.length - 1) {\n // console.log('last step', step.path);\n // points.push(step.path[1]);\n // points.push(step.path[2]);\n // }\n\n var coordinates = (0,_utils_coordinateSystems__WEBPACK_IMPORTED_MODULE_4__.convertVerticesToCoordinates)(points, null, 30.0);\n console.log(coordinates);\n this._updateMapLineData(coordinates, leg.floor);\n var currentFloor = this.map.getCurrentFloor();\n if (currentFloor !== leg.floor) {\n this.map.updateFloor(leg.floor, false);\n }\n }\n }, {\n key: \"_updateMapLineData\",\n value: function _updateMapLineData(newCoordinates, floor) {\n this.map.map.getSource('directionsLineSource').setData({\n 'type': 'Feature',\n 'properties': {\n '_floor': floor\n },\n 'geometry': {\n 'type': 'LineString',\n 'coordinates': newCoordinates\n }\n });\n var bounds = new mapboxgl.LngLatBounds();\n newCoordinates.forEach(function (coordinate) {\n bounds.extend(coordinate);\n });\n this.map.map.fitBounds(bounds, _defineProperty(_defineProperty(_defineProperty({\n padding: 200\n }, \"padding\", {\n top: 200,\n bottom: 200,\n left: 500,\n right: 150\n }), \"maxZoom\", 16), \"duration\", 1000));\n }\n }, {\n key: \"clearLineData\",\n value: function clearLineData() {\n this.map.map.getSource('directionsLineSource').setData({\n 'type': 'Feature',\n 'properties': {},\n 'geometry': {\n 'type': 'LineString',\n 'coordinates': []\n }\n });\n }\n }, {\n key: \"_handleDefaultState\",\n value: function _handleDefaultState() {\n this.hide();\n this.clearLineData();\n }\n }, {\n key: \"_handleSearchState\",\n value: function _handleSearchState(data) {\n var query = data.query,\n results = data.results;\n this.hide();\n this.clearLineData();\n }\n }, {\n key: \"_handleSelectedContentState\",\n value: function _handleSelectedContentState(data) {\n var contentPlacementIds = data.contentPlacementIds,\n selectedContentPlacement = data.selectedContentPlacement;\n this.hide();\n this.directionsView.updateView(null, null);\n this.clearLineData();\n // this.map.clearSelectedContentLayer();\n this.map.clearHighlightedContentLayer();\n }\n }, {\n key: \"_handleDirectionsState\",\n value: function _handleDirectionsState(data) {\n var startContentPlacement = data.startContentPlacement,\n endContentPlacement = data.endContentPlacement;\n this.show();\n this.clearLineData();\n this.directionsView.updateView(startContentPlacement, endContentPlacement);\n if (endContentPlacement) {\n var _convertVertexToCoord3 = (0,_utils_coordinateSystems__WEBPACK_IMPORTED_MODULE_4__.convertVertexToCoordinate)(endContentPlacement.location, null, 30.0),\n lat = _convertVertexToCoord3.lat,\n lon = _convertVertexToCoord3.lon;\n var coordinate = [lon, lat];\n if (!endContentPlacement.name) {\n if (endContentPlacement.content) {\n if (endContentPlacement.content.title_key) {\n var titleKey = endContentPlacement.content.title_key;\n var title = endContentPlacement.content.data[titleKey];\n endContentPlacement.name = title;\n }\n }\n }\n endContentPlacement._floor = endContentPlacement.floor;\n this.map.addSelectedFeature(coordinate, endContentPlacement);\n }\n }\n }, {\n key: \"_handleIntiateFindPath\",\n value: function () {\n var _handleIntiateFindPath2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(data) {\n var startContentPlacementId, endContentPlacementId;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n startContentPlacementId = data.startContentPlacementId, endContentPlacementId = data.endContentPlacementId;\n _context3.next = 3;\n return this.map.findPath(startContentPlacementId, endContentPlacementId);\n case 3:\n this.pathData = _context3.sent;\n this.directionsView.setNewPath(this.pathData);\n this.stepsView.setNewPath(this.pathData);\n this.updateMapForPathLeg(this.pathData.legs[0]);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this);\n }));\n function _handleIntiateFindPath(_x3) {\n return _handleIntiateFindPath2.apply(this, arguments);\n }\n return _handleIntiateFindPath;\n }()\n }, {\n key: \"_handleSelectDirectionsButton\",\n value: function _handleSelectDirectionsButton(data) {\n var placementId = data.placementId;\n }\n }, {\n key: \"_render\",\n value: function _render() {\n return;\n }\n }]);\n}(_core_Control__WEBPACK_IMPORTED_MODULE_0__[\"default\"]);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DirectionsControl);\n\n//# sourceURL=webpack://waygomaps/./src/Controls/DirectionsControl.js?");
|
|
596
596
|
|
|
597
597
|
/***/ }),
|
|
598
598
|
|
|
@@ -625,7 +625,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
625
625
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
626
626
|
|
|
627
627
|
"use strict";
|
|
628
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _components_SearchBox_SearchBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../components/SearchBox/SearchBox */ \"./src/components/SearchBox/SearchBox.js\");\n/* harmony import */ var _core_Control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../core/Control */ \"./src/core/Control.js\");\n/* harmony import */ var _WaygoMaps__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../WaygoMaps */ \"./src/WaygoMaps.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! axios */ \"./node_modules/axios/lib/axios.js\");\nfunction _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); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction 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); }\nfunction _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); }); }; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _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); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _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); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _superPropGet(t, e, r, o) { var p = _get(_getPrototypeOf(1 & o ? t.prototype : t), e, r); return 2 & o ? function (t) { return p.apply(r, t); } : p; }\nfunction _get() { return _get = \"undefined\" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }\nfunction _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\n\n\n\n\nvar SearchBoxControl = /*#__PURE__*/function (_Control) {\n function SearchBoxControl() {\n var _this;\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _classCallCheck(this, SearchBoxControl);\n _this = _callSuper(this, SearchBoxControl, [options]);\n _this.searchBox = new _components_SearchBox_SearchBox__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n _this.searchApi = _WaygoMaps__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getSearchApi();\n return _this;\n }\n _inherits(SearchBoxControl, _Control);\n return _createClass(SearchBoxControl, [{\n key: \"onAdd\",\n value: function onAdd(map) {\n this.map = map;\n this.container = document.createElement('div');\n this.container.className = 'search-box-control-container';\n var element = this.searchBox.getElement();\n this.container.appendChild(element);\n this._initializeEventListeners();\n this._attachResizeListener();\n this._initialize();\n this.show();\n return this.container;\n }\n }, {\n key: \"onRemove\",\n value: function onRemove() {\n _superPropGet(SearchBoxControl, \"onRemove\", this, 3)([]);\n }\n }, {\n key: \"_initializeEventListeners\",\n value: function _initializeEventListeners() {\n this.searchBox.searchBarSuggestionsView.on('selectCell', this._handleSuggestionSelect.bind(this));\n this.searchBox.searchBar.on('cancel', this._handleSearchBarCancel.bind(this));\n this.searchBox.on('search', this._handleSearchBoxSearch.bind(this));\n this.searchBox.on('selectBack', this._handleSearchBoxSelectBack.bind(this));\n this.searchBox.on('getSearchBarSuggestions', this._handleGettingSearchBarSuggestions.bind(this));\n this.map.on('state:default', this._handleDefaultState.bind(this));\n this.map.on('state:search', this._handleSearchState.bind(this));\n this.map.on('state:selectedContent', this._handleSelectedContentState.bind(this));\n this.map.on('state:directions', this._handleDirectionsState.bind(this));\n this.map.on('load', this._handleMapLoad.bind(this));\n }\n }, {\n key: \"_handleMapLoad\",\n value: function _handleMapLoad(data) {\n var mapData = data.mapData;\n var mapName = mapData.map_name;\n if (mapName) {\n this.searchBox.searchBar.setPlaceholderText(\"Search \".concat(mapName));\n } else {\n this.searchBox.searchBar.setPlaceholderText(\"Search\");\n }\n }\n }, {\n key: \"_handleGettingSearchBarSuggestions\",\n value: function () {\n var _handleGettingSearchBarSuggestions2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {\n var query, currentSearch, skip, limit, results;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n query = data.query;\n currentSearch = ++this.searchBox.searchCount;\n if (!(query === '')) {\n _context.next = 5;\n break;\n }\n this.searchBox.searchBarSuggestionsView.updateResults([]);\n return _context.abrupt(\"return\");\n case 5:\n if (this.map.mapData) {\n _context.next = 7;\n break;\n }\n return _context.abrupt(\"return\");\n case 7:\n skip = 0;\n limit = 5;\n _context.prev = 9;\n _context.next = 12;\n return this.searchApi.search(this.map.mapData.map_id, this.map.mapData.map_view_id, query, skip, limit);\n case 12:\n results = _context.sent;\n if (currentSearch === this.searchBox.searchCount) {\n this.searchBox.searchBarSuggestionsView.updateResults(results);\n }\n _context.next = 19;\n break;\n case 16:\n _context.prev = 16;\n _context.t0 = _context[\"catch\"](9);\n if (axios__WEBPACK_IMPORTED_MODULE_3__[\"default\"].isCancel(_context.t0)) {\n console.error('Request canceled:', _context.t0.message);\n } else {\n console.error('Search error:', _context.t0);\n }\n case 19:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[9, 16]]);\n }));\n function _handleGettingSearchBarSuggestions(_x) {\n return _handleGettingSearchBarSuggestions2.apply(this, arguments);\n }\n return _handleGettingSearchBarSuggestions;\n }()\n }, {\n key: \"_renderDesktopView\",\n value: function _renderDesktopView() {\n var element = this.searchBox.getElement();\n this.container.appendChild(element);\n this.container.classList.add('desktop-view');\n this.container.classList.remove('mobile-view');\n if (element) {\n this.searchBox.setViewForDesktop();\n }\n }\n }, {\n key: \"_renderMobileView\",\n value: function _renderMobileView() {\n var element = this.searchBox.getElement();\n this.container.appendChild(element);\n this.container.classList.add('mobile-view');\n this.container.classList.remove('desktop-view');\n if (element) {\n this.searchBox.setViewForMobile();\n }\n }\n }, {\n key: \"bringToFront\",\n value: function bringToFront() {\n /* z-index: 7; */\n this.container.style.zIndex = '10';\n }\n }, {\n key: \"bringBack\",\n value: function bringBack() {\n this.container.style.zIndex = '';\n }\n }, {\n key: \"_handleSearchBoxSelectBack\",\n value: function _handleSearchBoxSelectBack() {\n this.map.initiateBack();\n }\n }, {\n key: \"_handleSearchBarCancel\",\n value: function _handleSearchBarCancel(_) {\n this.map.setToDefaultState();\n }\n }, {\n key: \"_handleSearchBoxSearch\",\n value: function _handleSearchBoxSearch(data) {\n var query = data.query;\n this.map.setToSearchState(query);\n }\n }, {\n key: \"_handleSuggestionSelect\",\n value: function _handleSuggestionSelect(data) {\n var result = data.result;\n this.map.setToSelectedContentState([result.placement_id]);\n }\n }, {\n key: \"_handleDefaultState\",\n value: function _handleDefaultState() {\n this.searchBox.searchBarSuggestionsView.clearResults();\n this.searchBox.closeSuggestionsView();\n this.searchBox.searchBar.setText(\"\");\n this.searchBox.searchBar.updateRightButtonIcon('search');\n this.searchBox.searchBar.updateLeftButtonIcon('none');\n this.bringToFront();\n this.show();\n }\n }, {\n key: \"_handleSearchState\",\n value: function _handleSearchState(data) {\n var query = data.query,\n results = data.results;\n this.searchBox.searchBar.setText(query);\n this.searchBox.searchBar.updateRightButtonIcon('cancel');\n this.searchBox.searchBar.updateLeftButtonIcon('none');\n this.bringToFront();\n this.show();\n }\n }, {\n key: \"_handleSelectedContentState\",\n value: function _handleSelectedContentState(data) {\n var contentPlacementIds = data.contentPlacementIds,\n selectedContentPlacement = data.selectedContentPlacement;\n this.show();\n this.bringToFront();\n var title_key = selectedContentPlacement.content.title_key;\n var title = selectedContentPlacement.content.data[title_key];\n this.searchBox.searchBar.setText(title);\n this.searchBox.searchBar.updateRightButtonIcon('cancel');\n var stateHistoryLength = this.map._stateCoordinator.stateHistory.length;\n if (stateHistoryLength > 2 || contentPlacementIds.length > 1) {\n this.searchBox.searchBar.updateLeftButtonIcon('back');\n } else {\n this.searchBox.searchBar.updateLeftButtonIcon('none');\n }\n }\n }, {\n key: \"_handleDirectionsState\",\n value: function _handleDirectionsState(_) {\n this.bringBack();\n var stateHistoryLength = this.map._stateCoordinator.stateHistory.length;\n if (stateHistoryLength > 2) {\n this.searchBox.searchBar.updateLeftButtonIcon('back');\n } else {\n this.searchBox.searchBar.updateLeftButtonIcon('none');\n }\n }\n }]);\n}(_core_Control__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SearchBoxControl);\n\n//# sourceURL=webpack://waygomaps/./src/Controls/SearchBoxControl.js?");
|
|
628
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _components_SearchBox_SearchBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../components/SearchBox/SearchBox */ \"./src/components/SearchBox/SearchBox.js\");\n/* harmony import */ var _core_Control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../core/Control */ \"./src/core/Control.js\");\n/* harmony import */ var _WaygoMaps__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../WaygoMaps */ \"./src/WaygoMaps.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! axios */ \"./node_modules/axios/lib/axios.js\");\nfunction _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); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction 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); }\nfunction _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); }); }; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _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); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _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); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _superPropGet(t, e, r, o) { var p = _get(_getPrototypeOf(1 & o ? t.prototype : t), e, r); return 2 & o ? function (t) { return p.apply(r, t); } : p; }\nfunction _get() { return _get = \"undefined\" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }\nfunction _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\n\n\n\n\nvar SearchBoxControl = /*#__PURE__*/function (_Control) {\n function SearchBoxControl() {\n var _this;\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _classCallCheck(this, SearchBoxControl);\n _this = _callSuper(this, SearchBoxControl, [options]);\n _this.searchBox = new _components_SearchBox_SearchBox__WEBPACK_IMPORTED_MODULE_0__[\"default\"]();\n _this.searchApi = _WaygoMaps__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getSearchApi();\n return _this;\n }\n _inherits(SearchBoxControl, _Control);\n return _createClass(SearchBoxControl, [{\n key: \"onAdd\",\n value: function onAdd(map) {\n this.map = map;\n this.container = document.createElement('div');\n this.container.className = 'search-box-control-container';\n var element = this.searchBox.getElement();\n this.container.appendChild(element);\n this._initializeEventListeners();\n this._attachResizeListener();\n this._initialize();\n this.show();\n return this.container;\n }\n }, {\n key: \"onRemove\",\n value: function onRemove() {\n _superPropGet(SearchBoxControl, \"onRemove\", this, 3)([]);\n }\n }, {\n key: \"_initializeEventListeners\",\n value: function _initializeEventListeners() {\n this.searchBox.searchBarSuggestionsView.on('selectCell', this._handleSuggestionSelect.bind(this));\n this.searchBox.searchBar.on('cancel', this._handleSearchBarCancel.bind(this));\n this.searchBox.on('search', this._handleSearchBoxSearch.bind(this));\n this.searchBox.on('selectBack', this._handleSearchBoxSelectBack.bind(this));\n this.searchBox.on('getSearchBarSuggestions', this._handleGettingSearchBarSuggestions.bind(this));\n this.map.on('state:default', this._handleDefaultState.bind(this));\n this.map.on('state:search', this._handleSearchState.bind(this));\n this.map.on('state:selectedContent', this._handleSelectedContentState.bind(this));\n this.map.on('state:directions', this._handleDirectionsState.bind(this));\n this.map.on('load', this._handleMapLoad.bind(this));\n }\n }, {\n key: \"_handleMapLoad\",\n value: function _handleMapLoad(data) {\n var mapData = data.mapData;\n var mapName = mapData.map_name;\n if (mapName) {\n this.searchBox.searchBar.setPlaceholderText(\"Search \".concat(mapName));\n } else {\n this.searchBox.searchBar.setPlaceholderText(\"Search\");\n }\n }\n }, {\n key: \"_handleGettingSearchBarSuggestions\",\n value: function () {\n var _handleGettingSearchBarSuggestions2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {\n var query, currentSearch, skip, limit, results;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n query = data.query;\n currentSearch = ++this.searchBox.searchCount;\n if (!(query === '')) {\n _context.next = 5;\n break;\n }\n this.searchBox.searchBarSuggestionsView.updateResults([]);\n return _context.abrupt(\"return\");\n case 5:\n if (this.map.mapData) {\n _context.next = 7;\n break;\n }\n return _context.abrupt(\"return\");\n case 7:\n skip = 0;\n limit = 5;\n _context.prev = 9;\n _context.next = 12;\n return this.searchApi.search(this.map.mapData.map_id, this.map.mapData.map_view_id, query, skip, limit);\n case 12:\n results = _context.sent;\n if (currentSearch === this.searchBox.searchCount) {\n this.searchBox.searchBarSuggestionsView.updateResults(results);\n }\n _context.next = 19;\n break;\n case 16:\n _context.prev = 16;\n _context.t0 = _context[\"catch\"](9);\n if (axios__WEBPACK_IMPORTED_MODULE_3__[\"default\"].isCancel(_context.t0)) {\n console.error('Request canceled:', _context.t0.message);\n } else {\n console.error('Search error:', _context.t0);\n }\n case 19:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this, [[9, 16]]);\n }));\n function _handleGettingSearchBarSuggestions(_x) {\n return _handleGettingSearchBarSuggestions2.apply(this, arguments);\n }\n return _handleGettingSearchBarSuggestions;\n }()\n }, {\n key: \"_renderDesktopView\",\n value: function _renderDesktopView() {\n var element = this.searchBox.getElement();\n this.container.appendChild(element);\n this.container.classList.add('desktop-view');\n this.container.classList.remove('mobile-view');\n if (element) {\n this.searchBox.setViewForDesktop();\n }\n }\n }, {\n key: \"_renderMobileView\",\n value: function _renderMobileView() {\n var element = this.searchBox.getElement();\n this.container.appendChild(element);\n this.container.classList.add('mobile-view');\n this.container.classList.remove('desktop-view');\n if (element) {\n this.searchBox.setViewForMobile();\n }\n }\n }, {\n key: \"bringToFront\",\n value: function bringToFront() {\n /* z-index: 7; */\n this.container.style.zIndex = '10';\n }\n }, {\n key: \"bringBack\",\n value: function bringBack() {\n this.container.style.zIndex = '';\n }\n }, {\n key: \"_handleSearchBoxSelectBack\",\n value: function _handleSearchBoxSelectBack() {\n this.map.initiateBack();\n }\n }, {\n key: \"_handleSearchBarCancel\",\n value: function _handleSearchBarCancel(_) {\n this.map.setToDefaultState();\n }\n }, {\n key: \"_handleSearchBoxSearch\",\n value: function _handleSearchBoxSearch(data) {\n var query = data.query;\n this.map.setToSearchState(query);\n }\n }, {\n key: \"_handleSuggestionSelect\",\n value: function _handleSuggestionSelect(data) {\n var result = data.result;\n this.map.setToSelectedContentState([result.placement_id]);\n }\n }, {\n key: \"_handleDefaultState\",\n value: function _handleDefaultState() {\n this.searchBox.searchBarSuggestionsView.clearResults();\n this.searchBox.closeSuggestionsView();\n this.searchBox.searchBar.setText(\"\");\n this.searchBox.searchBar.updateRightButtonIcon('search');\n this.searchBox.searchBar.updateLeftButtonIcon('none');\n this.bringToFront();\n this.show();\n }\n }, {\n key: \"_handleSearchState\",\n value: function _handleSearchState(data) {\n var query = data.query,\n results = data.results;\n this.searchBox.searchBar.setText(query);\n this.searchBox.searchBar.updateRightButtonIcon('cancel');\n this.searchBox.searchBar.updateLeftButtonIcon('none');\n this.bringToFront();\n this.show();\n }\n }, {\n key: \"_handleSelectedContentState\",\n value: function _handleSelectedContentState(data) {\n var contentPlacementIds = data.contentPlacementIds,\n selectedContentPlacement = data.selectedContentPlacement;\n this.show();\n this.bringToFront();\n var title_key = selectedContentPlacement.content.title_key;\n var title = selectedContentPlacement.content.data[title_key];\n this.searchBox.searchBar.setText(title);\n this.searchBox.searchBar.updateRightButtonIcon('cancel');\n var stateHistoryLength = this.map._stateCoordinator.stateHistory.length;\n if (stateHistoryLength > 2 || contentPlacementIds.length > 1) {\n this.searchBox.searchBar.updateLeftButtonIcon('back');\n } else {\n this.searchBox.searchBar.updateLeftButtonIcon('none');\n }\n }\n }, {\n key: \"_handleDirectionsState\",\n value: function _handleDirectionsState(_) {\n this.bringBack();\n var stateHistoryLength = this.map._stateCoordinator.stateHistory.length;\n this.searchBox.searchBar.updateRightButtonIcon('cancel');\n if (stateHistoryLength > 2) {\n this.searchBox.searchBar.updateLeftButtonIcon('back');\n } else {\n this.searchBox.searchBar.updateLeftButtonIcon('none');\n }\n }\n }]);\n}(_core_Control__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SearchBoxControl);\n\n//# sourceURL=webpack://waygomaps/./src/Controls/SearchBoxControl.js?");
|
|
629
629
|
|
|
630
630
|
/***/ }),
|
|
631
631
|
|
|
@@ -779,7 +779,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
779
779
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
780
780
|
|
|
781
781
|
"use strict";
|
|
782
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var path_browserify__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! path-browserify */ \"./node_modules/path-browserify/index.js\");\n/* harmony import */ var path_browserify__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path_browserify__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _core_Component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../core/Component */ \"./src/core/Component.js\");\n/* harmony import */ var _SliderBar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../SliderBar */ \"./src/components/SliderBar.js\");\n/* harmony import */ var _assets_stepsIcons_StepLeft_svg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../assets/stepsIcons/StepLeft.svg */ \"./src/assets/stepsIcons/StepLeft.svg\");\n/* harmony import */ var _assets_stepsIcons_StepRight_svg__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../assets/stepsIcons/StepRight.svg */ \"./src/assets/stepsIcons/StepRight.svg\");\n/* harmony import */ var _assets_stepsIcons_StepArrival_svg__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../assets/stepsIcons/StepArrival.svg */ \"./src/assets/stepsIcons/StepArrival.svg\");\nfunction _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); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _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); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _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); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\n\n\n\n\n// import LeftIcon from \"../../assets/stepsIcons/step-left.svg\";\n// import RightIcon from \"../../assets/stepsIcons/step-right.svg\";\n\n\n\n\nvar StepsView = /*#__PURE__*/function (_Component) {\n function StepsView() {\n var _this;\n var steps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n _classCallCheck(this, StepsView);\n _this = _callSuper(this, StepsView, [options]);\n _this.pathData = null;\n _this.legSelector = null;\n _this.legSelectorContainerName = 'leg-selector';\n _this.selectedLegIndex = 0;\n _this._initialize();\n return _this;\n }\n _inherits(StepsView, _Component);\n return _createClass(StepsView, [{\n key: \"_initialize\",\n value: function _initialize() {\n this.element = document.createElement(\"div\");\n this.element.className = \"steps-view\";\n this._render();\n }\n }, {\n key: \"_createLegSelector\",\n value: function _createLegSelector(legs) {\n var legSelectorTitles = [];\n legs.forEach(function (leg) {\n legSelectorTitles.push(\"Floor \".concat(leg.floor));\n });\n var legSelector = new _SliderBar__WEBPACK_IMPORTED_MODULE_2__[\"default\"](legSelectorTitles, {\n container: this.legSelectorContainerName\n });\n legSelector.on(\"\".concat(this.legSelectorContainerName, \":selectNew\"), this._handleLegSelectorSelect.bind(this));\n return legSelector;\n }\n }, {\n key: \"_handleLegSelectorSelect\",\n value: function _handleLegSelectorSelect(data) {\n var index = data.index;\n if (index !== this.selectedLegIndex) {\n this.selectedLegIndex = index;\n this.fire('legSelect', data);\n this._render();\n }\n }\n }, {\n key: \"_render\",\n value: function _render() {\n var _this2 = this;\n this.element.innerHTML = \"\";\n if (!this.pathData) {\n this.element.style.display = \"none\";\n return;\n }\n\n // this.element.style.display = \"\";\n\n // const heading = document.createElement(\"h2\");\n // heading.textContent = \"Steps\";\n // this.element.appendChild(heading);\n\n // if (this.pathData.legs.length > 1) {\n // const legSelector = this._createLegSelector(this.pathData.legs);\n // this.element.appendChild(legSelector.getElement());\n // }\n\n // const list = document.createElement(\"ul\");\n // const leg = this.pathData.legs[this.selectedLegIndex];\n // leg.steps.forEach((step, index) => {\n // const listItem = document.createElement(\"li\");\n\n // let stepCount = index + 1;\n // if (this.selectedLegIndex !== 0) {\n // const previousStepCount = this.pathData.legs\n // .slice(0, this.selectedLegIndex)\n // .reduce((sum, item) => sum + item.steps.length, 0);\n // stepCount += previousStepCount;\n // }\n\n // // Step container\n // const stepContainer = document.createElement('div');\n // stepContainer.className = 'step-container';\n\n // // Step defatails container\n // const stepDetails = document.createElement(\"div\");\n // stepDetails.className = \"step-details\";\n\n // // Icon\n // const stepIcon = document.createElement(\"img\");\n // stepIcon.className = \"step-icon\";\n // if (stepCount === 1) {\n // stepIcon.src = ArrivalIcon;\n // } else if (step.instruction === 'left' || step.instruction === 'hard left') {\n // stepIcon.src = LeftIcon;\n // } else if (step.instruction === 'right' || step.instruction === 'hard right') {\n // stepIcon.src = RightIcon;\n // } else if (step.instruction === 'arrival') {\n // stepIcon.src = ArrivalIcon;\n // }\n // stepDetails.appendChild(stepIcon);\n\n // // Distance\n // if (index !== 0 && index !== leg.steps.length - 1) {\n // const stepDistance = document.createElement(\"div\");\n // stepDistance.className = \"step-distance\";\n // let distanceText = parseFloat(step.distance.toFixed(0));\n // console.log(step.distance);\n // if (this.pathData.unit === 'Feet') {\n // distanceText += ' FT';\n // } else if (this.pathData.unit === 'Meters') {\n // distanceText += ' M';\n // }\n // stepDistance.textContent = distanceText;\n // stepDetails.appendChild(stepDistance);\n // }\n\n // // Step header\n // // const stepHeader = document.createElement('div');\n // // stepHeader.className = 'step-header';\n // // stepHeader.textContent = `Step ${stepCount}`;\n // // stepDetails.appendChild(stepHeader);\n\n // console.log(`INSTRUCTION: ${step.instruction}`);\n\n // stepContainer.appendChild(stepDetails);\n\n // // Step instruction\n // const stepInstruction = document.createElement(\"div\");\n // stepInstruction.className = \"step-instruction\";\n // stepInstruction.textContent = step.text;\n // stepContainer.appendChild(stepInstruction);\n // // stepContainer.appendChild(stepInstruction);\n\n // // listItem.textContent = `Step ${stepCount}: ${step.text} (${step.distance} ${this.pathData.unit})`; //step;\n\n // listItem.appendChild(stepContainer);\n\n // list.appendChild(listItem);\n // });\n\n // this.element.appendChild(list);\n\n this.element.style.display = \"\";\n var heading = document.createElement(\"h2\");\n heading.textContent = \"Steps\";\n this.element.appendChild(heading);\n if (this.pathData.legs.length > 1) {\n this.legSelector = this._createLegSelector(this.pathData.legs);\n this.legSelector.selectButtonAtIndex(this.selectedLegIndex);\n this.element.appendChild(this.legSelector.getElement());\n }\n var list = document.createElement(\"ul\");\n var leg = this.pathData.legs[this.selectedLegIndex];\n leg.steps.forEach(function (step, index) {\n var listItem = document.createElement(\"li\");\n var stepCount = index + 1;\n if (_this2.selectedLegIndex !== 0) {\n var previousStepCount = _this2.pathData.legs.slice(0, _this2.selectedLegIndex).reduce(function (sum, item) {\n return sum + item.steps.length;\n }, 0);\n stepCount += previousStepCount;\n }\n\n // Step container\n var stepContainer = document.createElement('div');\n stepContainer.className = 'step-container';\n\n // Icon\n var stepIcon = document.createElement(\"img\");\n stepIcon.className = \"step-icon\";\n console.log(step.instruction);\n if (step.instruction === 'left' || step.instruction === 'hard left' || step.instruction === 'slight left') {\n stepIcon.src = _assets_stepsIcons_StepLeft_svg__WEBPACK_IMPORTED_MODULE_3__[\"default\"];\n } else if (step.instruction === 'right' || step.instruction === 'hard right' || step.instruction === 'slight right') {\n stepIcon.src = _assets_stepsIcons_StepRight_svg__WEBPACK_IMPORTED_MODULE_4__[\"default\"];\n } else if (step.instruction === 'arrival') {\n stepIcon.src = _assets_stepsIcons_StepArrival_svg__WEBPACK_IMPORTED_MODULE_5__[\"default\"];\n }\n stepContainer.appendChild(stepIcon);\n\n // Step defatails container\n var stepDetails = document.createElement(\"div\");\n stepDetails.className = \"step-details\";\n\n // Step header\n // const stepHeader = document.createElement('div');\n // stepHeader.className = 'step-header';\n // stepHeader.textContent = `Step ${stepCount}`;\n // stepDetails.appendChild(stepHeader);\n\n // Step instruction\n var stepInstruction = document.createElement(\"div\");\n stepInstruction.className = \"step-instruction\";\n stepInstruction.textContent = step.text;\n stepDetails.appendChild(stepInstruction);\n // stepContainer.appendChild(stepInstruction);\n\n stepContainer.appendChild(stepDetails);\n\n // listItem.textContent = `Step ${stepCount}: ${step.text} (${step.distance} ${this.pathData.unit})`; //step;\n\n if (index !== 0 && index !== leg.steps.length - 1) {\n // Distance\n var stepDistance = document.createElement(\"div\");\n stepDistance.className = \"step-distance\";\n var distanceText = parseFloat(step.distance.toFixed(0));\n if (_this2.pathData.unit === 'Feet') {\n distanceText += ' ft';\n } else if (_this2.pathData.unit === 'Meters') {\n distanceText += ' m';\n }\n stepDistance.textContent = distanceText;\n stepDetails.appendChild(stepDistance);\n // stepContainer.appendChild(stepDistance);\n }\n listItem.appendChild(stepContainer);\n list.appendChild(listItem);\n });\n this.element.appendChild(list);\n }\n }, {\n key: \"setNewPath\",\n value: function setNewPath(pathData) {\n this.pathData = pathData;\n this.selectedLegIndex = 0;\n this._render();\n }\n }, {\n key: \"getElement\",\n value: function getElement() {\n return this.element;\n }\n }]);\n}(_core_Component__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (StepsView);\n\n//# sourceURL=webpack://waygomaps/./src/components/DirectionsView/StepsView.js?");
|
|
782
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var path_browserify__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! path-browserify */ \"./node_modules/path-browserify/index.js\");\n/* harmony import */ var path_browserify__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path_browserify__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _core_Component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../core/Component */ \"./src/core/Component.js\");\n/* harmony import */ var _SliderBar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../SliderBar */ \"./src/components/SliderBar.js\");\n/* harmony import */ var _assets_stepsIcons_StepLeft_svg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../assets/stepsIcons/StepLeft.svg */ \"./src/assets/stepsIcons/StepLeft.svg\");\n/* harmony import */ var _assets_stepsIcons_StepRight_svg__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../assets/stepsIcons/StepRight.svg */ \"./src/assets/stepsIcons/StepRight.svg\");\n/* harmony import */ var _assets_stepsIcons_StepArrival_svg__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../assets/stepsIcons/StepArrival.svg */ \"./src/assets/stepsIcons/StepArrival.svg\");\nfunction _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); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _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); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _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); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\n\n\n\n\n// import LeftIcon from \"../../assets/stepsIcons/step-left.svg\";\n// import RightIcon from \"../../assets/stepsIcons/step-right.svg\";\n\n\n\n\nvar StepsView = /*#__PURE__*/function (_Component) {\n function StepsView() {\n var _this;\n var steps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n _classCallCheck(this, StepsView);\n _this = _callSuper(this, StepsView, [options]);\n _this.pathData = null;\n _this.legSelector = null;\n _this.legSelectorContainerName = 'leg-selector';\n _this.selectedLegIndex = 0;\n _this._initialize();\n return _this;\n }\n _inherits(StepsView, _Component);\n return _createClass(StepsView, [{\n key: \"_initialize\",\n value: function _initialize() {\n this.element = document.createElement(\"div\");\n this.element.className = \"steps-view\";\n this._render();\n }\n }, {\n key: \"_createLegSelector\",\n value: function _createLegSelector(legs) {\n var legSelectorTitles = [];\n legs.forEach(function (leg) {\n legSelectorTitles.push(\"Floor \".concat(leg.floor));\n });\n var legSelector = new _SliderBar__WEBPACK_IMPORTED_MODULE_2__[\"default\"](legSelectorTitles, {\n container: this.legSelectorContainerName\n });\n legSelector.on(\"\".concat(this.legSelectorContainerName, \":selectNew\"), this._handleLegSelectorSelect.bind(this));\n return legSelector;\n }\n }, {\n key: \"_handleLegSelectorSelect\",\n value: function _handleLegSelectorSelect(data) {\n var index = data.index;\n if (index !== this.selectedLegIndex) {\n this.selectedLegIndex = index;\n this.fire('legSelect', data);\n this._render();\n }\n }\n }, {\n key: \"_render\",\n value: function _render() {\n var _this2 = this;\n this.element.innerHTML = \"\";\n if (!this.pathData) {\n this.element.style.display = \"none\";\n return;\n }\n this.element.style.display = \"\";\n var heading = document.createElement(\"h2\");\n heading.textContent = \"Steps\";\n this.element.appendChild(heading);\n if (this.pathData.legs.length > 1) {\n this.legSelector = this._createLegSelector(this.pathData.legs);\n this.legSelector.selectButtonAtIndex(this.selectedLegIndex);\n this.element.appendChild(this.legSelector.getElement());\n }\n var list = document.createElement(\"ul\");\n var leg = this.pathData.legs[this.selectedLegIndex];\n leg.steps.forEach(function (step, index) {\n var listItem = document.createElement(\"li\");\n var stepCount = index + 1;\n if (_this2.selectedLegIndex !== 0) {\n var previousStepCount = _this2.pathData.legs.slice(0, _this2.selectedLegIndex).reduce(function (sum, item) {\n return sum + item.steps.length;\n }, 0);\n stepCount += previousStepCount;\n }\n\n // Step container\n var stepContainer = document.createElement('div');\n stepContainer.className = 'step-container';\n\n // Icon\n var stepIcon = document.createElement(\"img\");\n stepIcon.className = \"step-icon\";\n console.log(step.instruction);\n if (step.instruction === 'left' || step.instruction === 'hard left' || step.instruction === 'slight left') {\n stepIcon.src = _assets_stepsIcons_StepLeft_svg__WEBPACK_IMPORTED_MODULE_3__[\"default\"];\n } else if (step.instruction === 'right' || step.instruction === 'hard right' || step.instruction === 'slight right') {\n stepIcon.src = _assets_stepsIcons_StepRight_svg__WEBPACK_IMPORTED_MODULE_4__[\"default\"];\n } else if (step.instruction === 'arrival') {\n stepIcon.src = _assets_stepsIcons_StepArrival_svg__WEBPACK_IMPORTED_MODULE_5__[\"default\"];\n }\n stepContainer.appendChild(stepIcon);\n\n // Step defatails container\n var stepDetails = document.createElement(\"div\");\n stepDetails.className = \"step-details\";\n\n // Step header\n // const stepHeader = document.createElement('div');\n // stepHeader.className = 'step-header';\n // stepHeader.textContent = `Step ${stepCount}`;\n // stepDetails.appendChild(stepHeader);\n\n // Step instruction\n var stepInstruction = document.createElement(\"div\");\n stepInstruction.className = \"step-instruction\";\n stepInstruction.textContent = step.text;\n stepDetails.appendChild(stepInstruction);\n // stepContainer.appendChild(stepInstruction);\n\n stepContainer.appendChild(stepDetails);\n\n // listItem.textContent = `Step ${stepCount}: ${step.text} (${step.distance} ${this.pathData.unit})`; //step;\n\n if (index !== 0 && index !== leg.steps.length - 1) {\n // Distance\n var stepDistance = document.createElement(\"div\");\n stepDistance.className = \"step-distance\";\n var distanceText = parseFloat(step.distance.toFixed(0));\n if (_this2.pathData.unit === 'Feet') {\n distanceText += ' ft';\n } else if (_this2.pathData.unit === 'Meters') {\n distanceText += ' m';\n }\n stepDistance.textContent = distanceText;\n stepDetails.appendChild(stepDistance);\n // stepContainer.appendChild(stepDistance);\n }\n listItem.appendChild(stepContainer);\n list.appendChild(listItem);\n });\n this.element.appendChild(list);\n }\n }, {\n key: \"setNewPath\",\n value: function setNewPath(pathData) {\n this.pathData = pathData;\n this.selectedLegIndex = 0;\n this._render();\n }\n }, {\n key: \"getElement\",\n value: function getElement() {\n return this.element;\n }\n }]);\n}(_core_Component__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (StepsView);\n\n//# sourceURL=webpack://waygomaps/./src/components/DirectionsView/StepsView.js?");
|
|
783
783
|
|
|
784
784
|
/***/ }),
|
|
785
785
|
|
package/dist/style.css
CHANGED