@mapvx/web-js 1.1.1 → 1.2.1
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/cjs/domain/models/circle.js +253 -0
- package/dist/cjs/domain/models/circle.js.map +1 -0
- package/dist/cjs/index.js +7 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/logger/logger.js +1 -1
- package/dist/cjs/logger/rollbar.js +1 -1
- package/dist/cjs/map/map.js +345 -3
- package/dist/cjs/map/map.js.map +1 -1
- package/dist/es/domain/models/circle.d.ts +222 -0
- package/dist/es/domain/models/circle.d.ts.map +1 -0
- package/dist/es/domain/models/circle.js +246 -0
- package/dist/es/domain/models/circle.js.map +1 -0
- package/dist/es/index.d.ts +2 -0
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +2 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/logger/logger.js +1 -1
- package/dist/es/logger/rollbar.js +1 -1
- package/dist/es/map/map.d.ts +219 -0
- package/dist/es/map/map.d.ts.map +1 -1
- package/dist/es/map/map.js +345 -3
- package/dist/es/map/map.js.map +1 -1
- package/dist/umd/index.js +717 -31
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
package/dist/umd/index.js
CHANGED
|
@@ -5721,6 +5721,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
5721
5721
|
__webpack_require__.d(__webpack_exports__, {
|
|
5722
5722
|
AnnounceFormat: () => (/* reexport */ AnnounceFormat),
|
|
5723
5723
|
Banner: () => (/* reexport */ Banner),
|
|
5724
|
+
CIRCLE_DEFAULTS: () => (/* reexport */ CIRCLE_DEFAULTS),
|
|
5724
5725
|
CacheManager: () => (/* reexport */ CacheManager),
|
|
5725
5726
|
CountlyLogger: () => (/* reexport */ CountlyLogger),
|
|
5726
5727
|
DEFAULT_CACHE_CONFIGS: () => (/* reexport */ DEFAULT_CACHE_CONFIGS),
|
|
@@ -5728,6 +5729,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
5728
5729
|
FetchHttpClient: () => (/* reexport */ FetchHttpClient),
|
|
5729
5730
|
Institution: () => (/* reexport */ Institution),
|
|
5730
5731
|
LRUCache: () => (/* reexport */ LRUCache),
|
|
5732
|
+
MAPVX_BRAND_COLOR: () => (/* reexport */ MAPVX_BRAND_COLOR),
|
|
5731
5733
|
MAPVX_DEFAULT_PRECONNECT_HOSTS: () => (/* reexport */ MAPVX_DEFAULT_PRECONNECT_HOSTS),
|
|
5732
5734
|
MVXPlace: () => (/* reexport */ place_MVXPlace),
|
|
5733
5735
|
MVXRoute: () => (/* reexport */ MVXRoute),
|
|
@@ -5739,12 +5741,14 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
5739
5741
|
TextPosition: () => (/* reexport */ TextPosition),
|
|
5740
5742
|
TransportationMode: () => (/* reexport */ TransportationMode),
|
|
5741
5743
|
UnitSystem: () => (/* reexport */ UnitSystem),
|
|
5744
|
+
circleRing: () => (/* reexport */ circleRing),
|
|
5742
5745
|
createRouteAnimationIconDataUrl: () => (/* reexport */ createRouteAnimationIconDataUrl),
|
|
5743
5746
|
initializeSDK: () => (/* reexport */ initializeSDK),
|
|
5744
5747
|
injectPreconnects: () => (/* reexport */ injectPreconnects),
|
|
5745
5748
|
isBasicWithIcon: () => (/* reexport */ isBasicWithIcon),
|
|
5746
5749
|
isBasicWithLogo: () => (/* reexport */ isBasicWithLogo),
|
|
5747
5750
|
isMapVxRequestHostname: () => (/* reexport */ isMapVxRequestHostname),
|
|
5751
|
+
isValidCircleConfig: () => (/* reexport */ isValidCircleConfig),
|
|
5748
5752
|
loadCustomization: () => (/* reexport */ loadCustomization),
|
|
5749
5753
|
loadStyles: () => (/* binding */ loadStyles)
|
|
5750
5754
|
});
|
|
@@ -6790,7 +6794,7 @@ var rollbar_umd_min_default = /*#__PURE__*/__webpack_require__.n(rollbar_umd_min
|
|
|
6790
6794
|
// bundle. The tsc-built ES/CJS outputs keep it as a bare global, so the
|
|
6791
6795
|
// typeof guard makes the lookup safe everywhere; the version placeholder is
|
|
6792
6796
|
// replaced with the package version by scripts/inject-build-defines.js.
|
|
6793
|
-
var SDK_VERSION = true ? "1.
|
|
6797
|
+
var SDK_VERSION = true ? "1.2.1" : 0;
|
|
6794
6798
|
var _rollbarConfig = {
|
|
6795
6799
|
accessToken: "28279d52df43411ebd138c2bee0ab1df",
|
|
6796
6800
|
// Only report what the SDK logs explicitly via logError. Capturing every
|
|
@@ -6838,7 +6842,7 @@ var logger_countly = {
|
|
|
6838
6842
|
// The typeof guards make the lookup safe everywhere; the version placeholder
|
|
6839
6843
|
// is replaced with the package version by scripts/inject-build-defines.js.
|
|
6840
6844
|
var IS_DEBUG = true ? false : 0;
|
|
6841
|
-
var logger_SDK_VERSION = true ? "1.
|
|
6845
|
+
var logger_SDK_VERSION = true ? "1.2.1" : 0;
|
|
6842
6846
|
var Logger = /*#__PURE__*/function () {
|
|
6843
6847
|
function Logger() {
|
|
6844
6848
|
logger_classCallCheck(this, Logger);
|
|
@@ -9624,6 +9628,285 @@ var DEFAULT_TILE_CACHE_CONFIG = {
|
|
|
9624
9628
|
* @property apiUrl - (Optional) Injected by SDK when creating map; base API URL for map requests.
|
|
9625
9629
|
* @property mapvxRequestContext - (Optional) Injected by SDK when creating map; context sent as headers to public-api.mapvx.com.
|
|
9626
9630
|
*/
|
|
9631
|
+
;// ./src/domain/models/circle.ts
|
|
9632
|
+
function circle_typeof(o) { "@babel/helpers - typeof"; return circle_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; }, circle_typeof(o); }
|
|
9633
|
+
function circle_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9634
|
+
function circle_objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? circle_ownKeys(Object(t), !0).forEach(function (r) { circle_defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : circle_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9635
|
+
function circle_defineProperty(e, r, t) { return (r = circle_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
9636
|
+
function circle_toPropertyKey(t) { var i = circle_toPrimitive(t, "string"); return "symbol" == circle_typeof(i) ? i : i + ""; }
|
|
9637
|
+
function circle_toPrimitive(t, r) { if ("object" != circle_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != circle_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9638
|
+
|
|
9639
|
+
/**
|
|
9640
|
+
* MapVX brand color used as the default for circle styling and other
|
|
9641
|
+
* SDK-drawn overlays (colored places, borders).
|
|
9642
|
+
*
|
|
9643
|
+
* @group Circles
|
|
9644
|
+
*/
|
|
9645
|
+
var MAPVX_BRAND_COLOR = "#276EF1";
|
|
9646
|
+
|
|
9647
|
+
/**
|
|
9648
|
+
* Where a circle renders relative to the other map layers.
|
|
9649
|
+
*
|
|
9650
|
+
* - `"aboveBasemap"` (default): above every basemap geometry layer —
|
|
9651
|
+
* including indoor floor-plate and building polygons — but below the
|
|
9652
|
+
* labels that follow them. A circle is never occluded by basemap fills.
|
|
9653
|
+
* - `"belowLabels"`: below the first symbol (label) layer of the style.
|
|
9654
|
+
* On indoor styles, floor-plate polygons ordered after that layer will
|
|
9655
|
+
* paint over the circle.
|
|
9656
|
+
* - `"top"`: above everything, including labels and markers drawn in
|
|
9657
|
+
* style layers.
|
|
9658
|
+
*
|
|
9659
|
+
* @group Circles
|
|
9660
|
+
*/
|
|
9661
|
+
|
|
9662
|
+
/**
|
|
9663
|
+
* Valid values for {@link CircleRenderOrder}, in rendering order.
|
|
9664
|
+
* @internal
|
|
9665
|
+
*/
|
|
9666
|
+
var CIRCLE_RENDER_ORDERS = ["belowLabels", "aboveBasemap", "top"];
|
|
9667
|
+
|
|
9668
|
+
/**
|
|
9669
|
+
* Default styling values applied to a circle when the corresponding
|
|
9670
|
+
* {@link CircleConfig} fields are omitted.
|
|
9671
|
+
*
|
|
9672
|
+
* @group Circles
|
|
9673
|
+
*/
|
|
9674
|
+
var CIRCLE_DEFAULTS = {
|
|
9675
|
+
fillColor: MAPVX_BRAND_COLOR,
|
|
9676
|
+
fillOpacity: 0.14,
|
|
9677
|
+
strokeColor: MAPVX_BRAND_COLOR,
|
|
9678
|
+
strokeWidth: 2,
|
|
9679
|
+
strokeOpacity: 0.65,
|
|
9680
|
+
renderOrder: "aboveBasemap"
|
|
9681
|
+
};
|
|
9682
|
+
|
|
9683
|
+
/**
|
|
9684
|
+
* Represents the configuration for the creation of a metric radius circle on a map.
|
|
9685
|
+
* The radius is expressed in meters (geographic), so the drawn circle stays
|
|
9686
|
+
* metrically accurate at every zoom level.
|
|
9687
|
+
*
|
|
9688
|
+
* @example
|
|
9689
|
+
* ```typescript
|
|
9690
|
+
* const circleConfig: CircleConfig = {
|
|
9691
|
+
* id: "geofence-1",
|
|
9692
|
+
* coordinate: { lat: 40.7128, lng: -74.0060 },
|
|
9693
|
+
* radiusMeters: 150,
|
|
9694
|
+
* fillOpacity: 0.2,
|
|
9695
|
+
* };
|
|
9696
|
+
* ```
|
|
9697
|
+
*
|
|
9698
|
+
* @group Circles
|
|
9699
|
+
*/
|
|
9700
|
+
|
|
9701
|
+
/**
|
|
9702
|
+
* Internal resolved representation of a circle kept by the map.
|
|
9703
|
+
* Holds the full configuration with defaults applied, plus visibility state.
|
|
9704
|
+
*
|
|
9705
|
+
* Unlike markers, the hidden flag persists across floor changes and map
|
|
9706
|
+
* restyles: a circle hidden via `hideCircle` stays hidden until `showCircle`.
|
|
9707
|
+
*/
|
|
9708
|
+
|
|
9709
|
+
/**
|
|
9710
|
+
* Returns a deep copy of a {@link CircleRecord}, including the nested
|
|
9711
|
+
* coordinate. Used by the map accessors so callers can't mutate internal
|
|
9712
|
+
* circle state by writing to a returned record.
|
|
9713
|
+
*
|
|
9714
|
+
* @param record The circle record to clone.
|
|
9715
|
+
* @returns An independent copy of the record.
|
|
9716
|
+
*
|
|
9717
|
+
* @group Circles
|
|
9718
|
+
*/
|
|
9719
|
+
function cloneCircleRecord(record) {
|
|
9720
|
+
return circle_objectSpread(circle_objectSpread({}, record), {}, {
|
|
9721
|
+
coordinate: circle_objectSpread({}, record.coordinate)
|
|
9722
|
+
});
|
|
9723
|
+
}
|
|
9724
|
+
|
|
9725
|
+
/**
|
|
9726
|
+
* Validates that a radius in meters is positive and finite.
|
|
9727
|
+
* @param radius The radius value to validate.
|
|
9728
|
+
* @throws {Error} If radius is ≤ 0 or not finite (NaN/Infinity).
|
|
9729
|
+
* @internal
|
|
9730
|
+
*/
|
|
9731
|
+
function validateRadiusMeters(radius) {
|
|
9732
|
+
if (!Number.isFinite(radius) || radius <= 0) {
|
|
9733
|
+
throw new Error("Invalid radiusMeters: ".concat(radius, ". Must be a positive finite number."));
|
|
9734
|
+
}
|
|
9735
|
+
}
|
|
9736
|
+
|
|
9737
|
+
/**
|
|
9738
|
+
* Validates that a coordinate is within valid geographic bounds.
|
|
9739
|
+
* @param coord The coordinate to validate.
|
|
9740
|
+
* @throws {Error} If latitude is outside [-90, 90] or longitude outside [-180, 180], or not finite.
|
|
9741
|
+
* @internal
|
|
9742
|
+
*/
|
|
9743
|
+
function validateCoordinate(coord) {
|
|
9744
|
+
if (coord == null || circle_typeof(coord) !== "object") {
|
|
9745
|
+
throw new Error("Invalid coordinate: expected an object with lat and lng properties.");
|
|
9746
|
+
}
|
|
9747
|
+
if (!Number.isFinite(coord.lat) || !Number.isFinite(coord.lng) || coord.lat < -90 || coord.lat > 90 || coord.lng < -180 || coord.lng > 180) {
|
|
9748
|
+
throw new Error("Invalid coordinate: lat=".concat(coord.lat, ", lng=").concat(coord.lng, ". ") + "latitude must be in [-90, 90], longitude in [-180, 180], and both finite.");
|
|
9749
|
+
}
|
|
9750
|
+
}
|
|
9751
|
+
|
|
9752
|
+
/**
|
|
9753
|
+
* Clamps an opacity value to the valid range [0, 1].
|
|
9754
|
+
* @param opacity The opacity value to clamp.
|
|
9755
|
+
* @param defaultValue Value to use if opacity is not a finite number.
|
|
9756
|
+
* @returns The clamped opacity value.
|
|
9757
|
+
* @internal
|
|
9758
|
+
*/
|
|
9759
|
+
function clampOpacity(opacity, defaultValue) {
|
|
9760
|
+
if (!Number.isFinite(opacity)) return defaultValue;
|
|
9761
|
+
return Math.max(0, Math.min(1, opacity));
|
|
9762
|
+
}
|
|
9763
|
+
|
|
9764
|
+
/**
|
|
9765
|
+
* Type guard for validating circle configurations without throwing.
|
|
9766
|
+
* Returns true if the configuration is valid and can be added to the map.
|
|
9767
|
+
*
|
|
9768
|
+
* @param config Configuration to validate.
|
|
9769
|
+
* @returns True if config is a valid CircleConfig, false otherwise.
|
|
9770
|
+
*
|
|
9771
|
+
* @example
|
|
9772
|
+
* ```typescript
|
|
9773
|
+
* if (isValidCircleConfig(userInput)) {
|
|
9774
|
+
* map.addCircle(userInput);
|
|
9775
|
+
* } else {
|
|
9776
|
+
* console.error('Invalid circle configuration');
|
|
9777
|
+
* }
|
|
9778
|
+
* ```
|
|
9779
|
+
*
|
|
9780
|
+
* @group Circles
|
|
9781
|
+
*/
|
|
9782
|
+
function isValidCircleConfig(config) {
|
|
9783
|
+
if (config === null || config === undefined || circle_typeof(config) !== "object") {
|
|
9784
|
+
return false;
|
|
9785
|
+
}
|
|
9786
|
+
var c = config;
|
|
9787
|
+
if (circle_typeof(c.coordinate) !== "object" || c.coordinate === null) return false;
|
|
9788
|
+
var coord = c.coordinate;
|
|
9789
|
+
if (typeof coord.lat !== "number" || typeof coord.lng !== "number" || !Number.isFinite(coord.lat) || !Number.isFinite(coord.lng) || coord.lat < -90 || coord.lat > 90 || coord.lng < -180 || coord.lng > 180) {
|
|
9790
|
+
return false;
|
|
9791
|
+
}
|
|
9792
|
+
if (typeof c.radiusMeters !== "number" || !Number.isFinite(c.radiusMeters) || c.radiusMeters <= 0) {
|
|
9793
|
+
return false;
|
|
9794
|
+
}
|
|
9795
|
+
if (c.id !== undefined && typeof c.id !== "string") return false;
|
|
9796
|
+
if (c.fillColor !== undefined && typeof c.fillColor !== "string") return false;
|
|
9797
|
+
if (c.fillOpacity !== undefined) {
|
|
9798
|
+
if (typeof c.fillOpacity !== "number" || !Number.isFinite(c.fillOpacity)) return false;
|
|
9799
|
+
}
|
|
9800
|
+
if (c.strokeColor !== undefined && typeof c.strokeColor !== "string") return false;
|
|
9801
|
+
if (c.strokeWidth !== undefined) {
|
|
9802
|
+
if (typeof c.strokeWidth !== "number" || !Number.isFinite(c.strokeWidth)) return false;
|
|
9803
|
+
}
|
|
9804
|
+
if (c.strokeOpacity !== undefined) {
|
|
9805
|
+
if (typeof c.strokeOpacity !== "number" || !Number.isFinite(c.strokeOpacity)) return false;
|
|
9806
|
+
}
|
|
9807
|
+
if (c.floorId !== undefined && typeof c.floorId !== "string") return false;
|
|
9808
|
+
if (c.renderOrder !== undefined && !CIRCLE_RENDER_ORDERS.includes(c.renderOrder)) {
|
|
9809
|
+
return false;
|
|
9810
|
+
}
|
|
9811
|
+
return true;
|
|
9812
|
+
}
|
|
9813
|
+
|
|
9814
|
+
/**
|
|
9815
|
+
* Resolves a {@link CircleConfig} into a {@link CircleRecord}, applying
|
|
9816
|
+
* default styling, generating an id when one is not provided, and validating inputs.
|
|
9817
|
+
*
|
|
9818
|
+
* @param config Circle configuration provided by the SDK consumer.
|
|
9819
|
+
* @param hidden Initial hidden state, defaults to visible.
|
|
9820
|
+
* @returns The resolved circle record ready to be stored and rendered.
|
|
9821
|
+
* @throws {Error} If radiusMeters is ≤ 0, not finite, or coordinates are invalid.
|
|
9822
|
+
*
|
|
9823
|
+
* @group Circles
|
|
9824
|
+
*/
|
|
9825
|
+
function resolveCircleConfig(config) {
|
|
9826
|
+
var _config$id, _config$fillColor, _config$strokeColor, _config$strokeWidth, _config$renderOrder;
|
|
9827
|
+
var hidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
9828
|
+
validateRadiusMeters(config.radiusMeters);
|
|
9829
|
+
validateCoordinate(config.coordinate);
|
|
9830
|
+
if (config.renderOrder !== undefined && !CIRCLE_RENDER_ORDERS.includes(config.renderOrder)) {
|
|
9831
|
+
throw new Error("Invalid renderOrder: ".concat(String(config.renderOrder), ". ") + "Must be one of: ".concat(CIRCLE_RENDER_ORDERS.join(", "), "."));
|
|
9832
|
+
}
|
|
9833
|
+
return {
|
|
9834
|
+
id: (_config$id = config.id) !== null && _config$id !== void 0 ? _config$id : generateHexadecimalKey(),
|
|
9835
|
+
// Copy the coordinate so later mutations of the caller's object
|
|
9836
|
+
// can't change internal circle state
|
|
9837
|
+
coordinate: {
|
|
9838
|
+
lat: config.coordinate.lat,
|
|
9839
|
+
lng: config.coordinate.lng
|
|
9840
|
+
},
|
|
9841
|
+
radiusMeters: config.radiusMeters,
|
|
9842
|
+
fillColor: (_config$fillColor = config.fillColor) !== null && _config$fillColor !== void 0 ? _config$fillColor : CIRCLE_DEFAULTS.fillColor,
|
|
9843
|
+
fillOpacity: clampOpacity(config.fillOpacity, CIRCLE_DEFAULTS.fillOpacity),
|
|
9844
|
+
strokeColor: (_config$strokeColor = config.strokeColor) !== null && _config$strokeColor !== void 0 ? _config$strokeColor : CIRCLE_DEFAULTS.strokeColor,
|
|
9845
|
+
strokeWidth: (_config$strokeWidth = config.strokeWidth) !== null && _config$strokeWidth !== void 0 ? _config$strokeWidth : CIRCLE_DEFAULTS.strokeWidth,
|
|
9846
|
+
strokeOpacity: clampOpacity(config.strokeOpacity, CIRCLE_DEFAULTS.strokeOpacity),
|
|
9847
|
+
floorId: config.floorId,
|
|
9848
|
+
renderOrder: (_config$renderOrder = config.renderOrder) !== null && _config$renderOrder !== void 0 ? _config$renderOrder : CIRCLE_DEFAULTS.renderOrder,
|
|
9849
|
+
hidden: hidden
|
|
9850
|
+
};
|
|
9851
|
+
}
|
|
9852
|
+
|
|
9853
|
+
/**
|
|
9854
|
+
* Builds a closed GeoJSON polygon ring approximating a geographic circle.
|
|
9855
|
+
*
|
|
9856
|
+
* The ring is computed with an equirectangular approximation: meters are
|
|
9857
|
+
* converted to degrees independently per axis, with the longitude scale
|
|
9858
|
+
* corrected by the cosine of the latitude. For the radii the SDK works with
|
|
9859
|
+
* (tens to hundreds of meters) the metric error is negligible (≤1%) at any latitude
|
|
9860
|
+
* where the projection is defined. At extreme polar latitudes, the approximation
|
|
9861
|
+
* breaks down, so circles near poles (|lat| > 85°) should be used with caution.
|
|
9862
|
+
*
|
|
9863
|
+
* @param lng Longitude of the circle center in degrees.
|
|
9864
|
+
* @param lat Latitude of the circle center in degrees.
|
|
9865
|
+
* @param radiusMeters Radius of the circle in meters. Must be positive and finite.
|
|
9866
|
+
* @param points Number of segments in the ring. Defaults to 64. Non-integer
|
|
9867
|
+
* values are floored and the count is clamped to a minimum of 3,
|
|
9868
|
+
* the smallest valid GeoJSON linear ring; non-finite values fall
|
|
9869
|
+
* back to the default.
|
|
9870
|
+
* @returns A closed ring of `[lng, lat]` positions (first equals last).
|
|
9871
|
+
*
|
|
9872
|
+
* @example
|
|
9873
|
+
* ```typescript
|
|
9874
|
+
* import { circleRing } from '@mapvx/web-js';
|
|
9875
|
+
*
|
|
9876
|
+
* // Create a 150-meter radius circle ring
|
|
9877
|
+
* const ring = circleRing(-74.0060, 40.7128, 150);
|
|
9878
|
+
* const polygon = { type: "Polygon", coordinates: [ring] };
|
|
9879
|
+
*
|
|
9880
|
+
* // Custom segments (32 instead of 64) for lower resolution
|
|
9881
|
+
* const coarseRing = circleRing(-74.0060, 40.7128, 150, 32);
|
|
9882
|
+
* ```
|
|
9883
|
+
*
|
|
9884
|
+
* @note Equirectangular approximation is accurate for radii up to ~500 km and
|
|
9885
|
+
* latitudes between approximately ±80°. Beyond these limits, visual
|
|
9886
|
+
* distortion may occur near the poles.
|
|
9887
|
+
* @note Generated rings do not account for geographic obstacles, walls, or
|
|
9888
|
+
* buildings. For complex geofencing, consider server-side validation.
|
|
9889
|
+
*
|
|
9890
|
+
* @group Circles
|
|
9891
|
+
*/
|
|
9892
|
+
function circleRing(lng, lat, radiusMeters) {
|
|
9893
|
+
var points = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 64;
|
|
9894
|
+
// A linear ring needs at least 3 distinct positions to be valid GeoJSON
|
|
9895
|
+
var segments = Number.isFinite(points) ? Math.max(3, Math.floor(points)) : 64;
|
|
9896
|
+
var ring = [];
|
|
9897
|
+
var latRad = lat * Math.PI / 180;
|
|
9898
|
+
var metersPerDegLat = 110574;
|
|
9899
|
+
var metersPerDegLng = 111320 * Math.cos(latRad || 0.000001);
|
|
9900
|
+
var latR = radiusMeters / metersPerDegLat;
|
|
9901
|
+
var lngR = radiusMeters / (metersPerDegLng || 1);
|
|
9902
|
+
for (var i = 0; i < segments; i += 1) {
|
|
9903
|
+
var a = i / segments * Math.PI * 2;
|
|
9904
|
+
ring.push([lng + lngR * Math.cos(a), lat + latR * Math.sin(a)]);
|
|
9905
|
+
}
|
|
9906
|
+
// Close the ring with an exact copy of the first position, as GeoJSON requires
|
|
9907
|
+
ring.push([ring[0][0], ring[0][1]]);
|
|
9908
|
+
return ring;
|
|
9909
|
+
}
|
|
9627
9910
|
;// ./node_modules/.pnpm/@googlemaps+polyline-codec@1.0.28/node_modules/@googlemaps/polyline-codec/dist/index.esm.js
|
|
9628
9911
|
/**
|
|
9629
9912
|
* Copyright 2020 Google LLC
|
|
@@ -13186,11 +13469,11 @@ function map_regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-prese
|
|
|
13186
13469
|
function map_regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } map_regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { map_regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, map_regeneratorDefine2(e, r, n, t); }
|
|
13187
13470
|
function map_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); }
|
|
13188
13471
|
function map_asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { map_asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { map_asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
13189
|
-
function map_createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = map_unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
13190
13472
|
function map_slicedToArray(r, e) { return map_arrayWithHoles(r) || map_iterableToArrayLimit(r, e) || map_unsupportedIterableToArray(r, e) || map_nonIterableRest(); }
|
|
13191
13473
|
function map_nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13192
13474
|
function map_iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13193
13475
|
function map_arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13476
|
+
function map_createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = map_unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
13194
13477
|
function map_toConsumableArray(r) { return map_arrayWithoutHoles(r) || map_iterableToArray(r) || map_unsupportedIterableToArray(r) || map_nonIterableSpread(); }
|
|
13195
13478
|
function map_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."); }
|
|
13196
13479
|
function map_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return map_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) ? map_arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -13213,6 +13496,36 @@ function map_defineProperty(e, r, t) { return (r = map_toPropertyKey(r)) in e ?
|
|
|
13213
13496
|
function map_toPropertyKey(t) { var i = map_toPrimitive(t, "string"); return "symbol" == map_typeof(i) ? i : i + ""; }
|
|
13214
13497
|
function map_toPrimitive(t, r) { if ("object" != map_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != map_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13215
13498
|
|
|
13499
|
+
/** Shared GeoJSON source holding every circle drawn through the circle API. */
|
|
13500
|
+
var CIRCLE_SOURCE_ID = "mapvx-circles";
|
|
13501
|
+
/** Fill layer rendering the translucent interior of the circles. */
|
|
13502
|
+
var CIRCLE_FILL_LAYER_ID = "mapvx-circles-fill";
|
|
13503
|
+
/** Line layer rendering the circle outlines. */
|
|
13504
|
+
var CIRCLE_LINE_LAYER_ID = "mapvx-circles-line";
|
|
13505
|
+
|
|
13506
|
+
/**
|
|
13507
|
+
* Layer-id suffix per circle render order. The default placement keeps the
|
|
13508
|
+
* unsuffixed ids so existing consumers referencing them keep working.
|
|
13509
|
+
*/
|
|
13510
|
+
var CIRCLE_LAYER_SUFFIXES = {
|
|
13511
|
+
aboveBasemap: "",
|
|
13512
|
+
belowLabels: "-below-labels",
|
|
13513
|
+
top: "-top"
|
|
13514
|
+
};
|
|
13515
|
+
|
|
13516
|
+
/** Fill/line layer ids for one circle render-order bucket. */
|
|
13517
|
+
function circleLayerIdsFor(order) {
|
|
13518
|
+
var suffix = CIRCLE_LAYER_SUFFIXES[order];
|
|
13519
|
+
return {
|
|
13520
|
+
fill: CIRCLE_FILL_LAYER_ID + suffix,
|
|
13521
|
+
line: CIRCLE_LINE_LAYER_ID + suffix
|
|
13522
|
+
};
|
|
13523
|
+
}
|
|
13524
|
+
|
|
13525
|
+
/** True for the layer ids owned by the circle API, regardless of bucket. */
|
|
13526
|
+
function isCircleLayerId(id) {
|
|
13527
|
+
return id.startsWith(CIRCLE_FILL_LAYER_ID) || id.startsWith(CIRCLE_LINE_LAYER_ID);
|
|
13528
|
+
}
|
|
13216
13529
|
|
|
13217
13530
|
// Flag to track if cached-tile protocol has been registered
|
|
13218
13531
|
var cachedTileProtocolRegistered = false;
|
|
@@ -13327,6 +13640,7 @@ function convertPaddingToPixels(padding, containerWidth, containerHeight) {
|
|
|
13327
13640
|
|
|
13328
13641
|
|
|
13329
13642
|
|
|
13643
|
+
|
|
13330
13644
|
/**
|
|
13331
13645
|
* @group Map
|
|
13332
13646
|
*/
|
|
@@ -13356,6 +13670,7 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
13356
13670
|
map_defineProperty(_this, "currentFloor", "");
|
|
13357
13671
|
map_defineProperty(_this, "baseFilters", {});
|
|
13358
13672
|
map_defineProperty(_this, "markers", []);
|
|
13673
|
+
map_defineProperty(_this, "circles", []);
|
|
13359
13674
|
map_defineProperty(_this, "enableHover", false);
|
|
13360
13675
|
map_defineProperty(_this, "hoveredId", "unselected");
|
|
13361
13676
|
map_defineProperty(_this, "failedTiles", new Set());
|
|
@@ -13522,6 +13837,11 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
13522
13837
|
_this6.onHover();
|
|
13523
13838
|
_this6.subscribeToFailedTiles();
|
|
13524
13839
|
});
|
|
13840
|
+
// Self-healing for circles: a full style reload wipes custom sources and
|
|
13841
|
+
// layers, and not every restyle path goes through whenStyleUpdates.
|
|
13842
|
+
this.map.on("styledata", function () {
|
|
13843
|
+
if (_this6.circles.length > 0) _this6.ensureCircleLayers();
|
|
13844
|
+
});
|
|
13525
13845
|
this.map.on("zoomend", function () {
|
|
13526
13846
|
var _mapConfig$onZoomEnd;
|
|
13527
13847
|
(_mapConfig$onZoomEnd = mapConfig.onZoomEnd) === null || _mapConfig$onZoomEnd === void 0 || _mapConfig$onZoomEnd.call(mapConfig, _this6.getZoomLevel());
|
|
@@ -13619,6 +13939,7 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
13619
13939
|
}, {
|
|
13620
13940
|
key: "destroyMap",
|
|
13621
13941
|
value: function destroyMap() {
|
|
13942
|
+
this.circles = [];
|
|
13622
13943
|
this.map.remove();
|
|
13623
13944
|
this.unsubscribeFromFailedTiles();
|
|
13624
13945
|
}
|
|
@@ -13756,6 +14077,7 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
13756
14077
|
this.setBaseFilters(newStyle);
|
|
13757
14078
|
}
|
|
13758
14079
|
this.routeController.addSourcesAndLayers();
|
|
14080
|
+
this.refreshCircles();
|
|
13759
14081
|
this.filterByFloorKey(this.currentFloor);
|
|
13760
14082
|
}
|
|
13761
14083
|
}, {
|
|
@@ -13884,6 +14206,367 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
13884
14206
|
throw new Error("Failed to remove all markers");
|
|
13885
14207
|
}
|
|
13886
14208
|
}
|
|
14209
|
+
}, {
|
|
14210
|
+
key: "addCircle",
|
|
14211
|
+
value: function addCircle(circle) {
|
|
14212
|
+
try {
|
|
14213
|
+
// Check if a circle with the same ID already exists and replace it
|
|
14214
|
+
if (circle.id) {
|
|
14215
|
+
this.circles = this.circles.filter(function (c) {
|
|
14216
|
+
return c.id !== circle.id;
|
|
14217
|
+
});
|
|
14218
|
+
}
|
|
14219
|
+
// resolveCircleConfig validates radiusMeters and coordinates
|
|
14220
|
+
var record = resolveCircleConfig(circle);
|
|
14221
|
+
this.circles.push(record);
|
|
14222
|
+
this.refreshCircles();
|
|
14223
|
+
this.logEvent("addCircle");
|
|
14224
|
+
return record.id;
|
|
14225
|
+
} catch (error) {
|
|
14226
|
+
throw new Error("Failed to add circle: ".concat(error instanceof Error ? error.message : String(error)));
|
|
14227
|
+
}
|
|
14228
|
+
}
|
|
14229
|
+
}, {
|
|
14230
|
+
key: "updateCircle",
|
|
14231
|
+
value: function updateCircle(circleConfig) {
|
|
14232
|
+
try {
|
|
14233
|
+
var index = this.circles.findIndex(function (c) {
|
|
14234
|
+
return c.id === circleConfig.id;
|
|
14235
|
+
});
|
|
14236
|
+
if (index === -1) return null;
|
|
14237
|
+
|
|
14238
|
+
// resolveCircleConfig validates radiusMeters and coordinates
|
|
14239
|
+
this.circles[index] = resolveCircleConfig(circleConfig, this.circles[index].hidden);
|
|
14240
|
+
this.refreshCircles();
|
|
14241
|
+
this.logEvent("updateCircle");
|
|
14242
|
+
return this.circles[index].id;
|
|
14243
|
+
} catch (error) {
|
|
14244
|
+
throw new Error("Failed to update circle: ".concat(error instanceof Error ? error.message : String(error)));
|
|
14245
|
+
}
|
|
14246
|
+
}
|
|
14247
|
+
}, {
|
|
14248
|
+
key: "getCircle",
|
|
14249
|
+
value: function getCircle(circleId) {
|
|
14250
|
+
var circle = this.circles.find(function (c) {
|
|
14251
|
+
return c.id === circleId;
|
|
14252
|
+
});
|
|
14253
|
+
return circle ? cloneCircleRecord(circle) : undefined;
|
|
14254
|
+
}
|
|
14255
|
+
}, {
|
|
14256
|
+
key: "getCircles",
|
|
14257
|
+
value: function getCircles() {
|
|
14258
|
+
return this.circles.map(cloneCircleRecord);
|
|
14259
|
+
}
|
|
14260
|
+
}, {
|
|
14261
|
+
key: "hasCircle",
|
|
14262
|
+
value: function hasCircle(circleId) {
|
|
14263
|
+
return this.circles.some(function (c) {
|
|
14264
|
+
return c.id === circleId;
|
|
14265
|
+
});
|
|
14266
|
+
}
|
|
14267
|
+
}, {
|
|
14268
|
+
key: "updateCirclePosition",
|
|
14269
|
+
value: function updateCirclePosition(circleId, center, radiusMeters) {
|
|
14270
|
+
try {
|
|
14271
|
+
var _circle = this.circles.find(function (c) {
|
|
14272
|
+
return c.id === circleId;
|
|
14273
|
+
});
|
|
14274
|
+
if (_circle === undefined) return false;
|
|
14275
|
+
|
|
14276
|
+
// Validate inputs before modifying
|
|
14277
|
+
if (!center) {
|
|
14278
|
+
throw new Error("Circle center is required");
|
|
14279
|
+
}
|
|
14280
|
+
var lat = center.lat,
|
|
14281
|
+
lng = center.lng;
|
|
14282
|
+
if (!Number.isFinite(lat) || lat < -90 || lat > 90) {
|
|
14283
|
+
throw new Error("Invalid latitude: ".concat(lat, ". Must be between -90 and 90."));
|
|
14284
|
+
}
|
|
14285
|
+
if (!Number.isFinite(lng) || lng < -180 || lng > 180) {
|
|
14286
|
+
throw new Error("Invalid longitude: ".concat(lng, ". Must be between -180 and 180."));
|
|
14287
|
+
}
|
|
14288
|
+
if (radiusMeters !== undefined) {
|
|
14289
|
+
if (!Number.isFinite(radiusMeters) || radiusMeters <= 0) {
|
|
14290
|
+
throw new Error("Invalid radiusMeters: ".concat(radiusMeters, ". Must be a positive finite number."));
|
|
14291
|
+
}
|
|
14292
|
+
}
|
|
14293
|
+
_circle.coordinate = {
|
|
14294
|
+
lat: center.lat,
|
|
14295
|
+
lng: center.lng
|
|
14296
|
+
};
|
|
14297
|
+
if (radiusMeters !== undefined) {
|
|
14298
|
+
_circle.radiusMeters = radiusMeters;
|
|
14299
|
+
}
|
|
14300
|
+
this.refreshCircles();
|
|
14301
|
+
this.logEvent("updateCirclePosition");
|
|
14302
|
+
return true;
|
|
14303
|
+
} catch (error) {
|
|
14304
|
+
throw new Error("Failed to update circle position: ".concat(error instanceof Error ? error.message : String(error)));
|
|
14305
|
+
}
|
|
14306
|
+
}
|
|
14307
|
+
}, {
|
|
14308
|
+
key: "updateCircleStyle",
|
|
14309
|
+
value: function updateCircleStyle(circleId, style) {
|
|
14310
|
+
try {
|
|
14311
|
+
var _circle2 = this.circles.find(function (c) {
|
|
14312
|
+
return c.id === circleId;
|
|
14313
|
+
});
|
|
14314
|
+
if (_circle2 === undefined) return false;
|
|
14315
|
+
|
|
14316
|
+
// Update only style properties, clamp opacities
|
|
14317
|
+
if (style.fillColor !== undefined) _circle2.fillColor = style.fillColor;
|
|
14318
|
+
if (style.fillOpacity !== undefined) _circle2.fillOpacity = Math.max(0, Math.min(1, style.fillOpacity));
|
|
14319
|
+
if (style.strokeColor !== undefined) _circle2.strokeColor = style.strokeColor;
|
|
14320
|
+
if (style.strokeWidth !== undefined) _circle2.strokeWidth = style.strokeWidth;
|
|
14321
|
+
if (style.strokeOpacity !== undefined) _circle2.strokeOpacity = Math.max(0, Math.min(1, style.strokeOpacity));
|
|
14322
|
+
this.refreshCircles();
|
|
14323
|
+
this.logEvent("updateCircleStyle");
|
|
14324
|
+
return true;
|
|
14325
|
+
} catch (error) {
|
|
14326
|
+
throw new Error("Failed to update circle style: ".concat(error instanceof Error ? error.message : String(error)));
|
|
14327
|
+
}
|
|
14328
|
+
}
|
|
14329
|
+
}, {
|
|
14330
|
+
key: "removeCircle",
|
|
14331
|
+
value: function removeCircle(circleId) {
|
|
14332
|
+
try {
|
|
14333
|
+
this.circles = this.circles.filter(function (c) {
|
|
14334
|
+
return c.id !== circleId;
|
|
14335
|
+
});
|
|
14336
|
+
this.refreshCircles();
|
|
14337
|
+
this.logEvent("removeCircle");
|
|
14338
|
+
} catch (error) {
|
|
14339
|
+
throw new Error("Failed to remove circle");
|
|
14340
|
+
}
|
|
14341
|
+
}
|
|
14342
|
+
}, {
|
|
14343
|
+
key: "removeAllCircles",
|
|
14344
|
+
value: function removeAllCircles() {
|
|
14345
|
+
try {
|
|
14346
|
+
this.circles = [];
|
|
14347
|
+
this.refreshCircles();
|
|
14348
|
+
this.logEvent("removeAllCircles");
|
|
14349
|
+
} catch (error) {
|
|
14350
|
+
throw new Error("Failed to remove all circles");
|
|
14351
|
+
}
|
|
14352
|
+
}
|
|
14353
|
+
}, {
|
|
14354
|
+
key: "showCircle",
|
|
14355
|
+
value: function showCircle(circleId) {
|
|
14356
|
+
try {
|
|
14357
|
+
var _circle3 = this.circles.find(function (c) {
|
|
14358
|
+
return c.id === circleId;
|
|
14359
|
+
});
|
|
14360
|
+
if (_circle3 === undefined) {
|
|
14361
|
+
return false;
|
|
14362
|
+
}
|
|
14363
|
+
_circle3.hidden = false;
|
|
14364
|
+
this.refreshCircles();
|
|
14365
|
+
this.logEvent("showCircle");
|
|
14366
|
+
return true;
|
|
14367
|
+
} catch (error) {
|
|
14368
|
+
return false;
|
|
14369
|
+
}
|
|
14370
|
+
}
|
|
14371
|
+
}, {
|
|
14372
|
+
key: "hideCircle",
|
|
14373
|
+
value: function hideCircle(circleId) {
|
|
14374
|
+
try {
|
|
14375
|
+
var _circle4 = this.circles.find(function (c) {
|
|
14376
|
+
return c.id === circleId;
|
|
14377
|
+
});
|
|
14378
|
+
if (_circle4 === undefined) {
|
|
14379
|
+
return false;
|
|
14380
|
+
}
|
|
14381
|
+
_circle4.hidden = true;
|
|
14382
|
+
this.refreshCircles();
|
|
14383
|
+
this.logEvent("hideCircle");
|
|
14384
|
+
return true;
|
|
14385
|
+
} catch (error) {
|
|
14386
|
+
return false;
|
|
14387
|
+
}
|
|
14388
|
+
}
|
|
14389
|
+
|
|
14390
|
+
/**
|
|
14391
|
+
* Builds the GeoJSON FeatureCollection for every currently visible circle.
|
|
14392
|
+
* Visibility mirrors marker semantics: a circle with a floor is shown only
|
|
14393
|
+
* while that floor is displayed, and a circle without a floor is shown only
|
|
14394
|
+
* in outdoor contexts. Hidden circles are always omitted.
|
|
14395
|
+
*/
|
|
14396
|
+
}, {
|
|
14397
|
+
key: "circleFeatureCollection",
|
|
14398
|
+
value: function circleFeatureCollection() {
|
|
14399
|
+
var _this$currentFloor3, _this$innerFloors$fin6, _this$innerFloors$fin7;
|
|
14400
|
+
var floorId = (_this$currentFloor3 = this.currentFloor) !== null && _this$currentFloor3 !== void 0 ? _this$currentFloor3 : "";
|
|
14401
|
+
var isOutdoor = !this.parentPlace || ((_this$innerFloors$fin6 = (_this$innerFloors$fin7 = this.innerFloors.find(function (floor) {
|
|
14402
|
+
return floor.key === floorId;
|
|
14403
|
+
})) === null || _this$innerFloors$fin7 === void 0 ? void 0 : _this$innerFloors$fin7.reachableFromGPS) !== null && _this$innerFloors$fin6 !== void 0 ? _this$innerFloors$fin6 : false);
|
|
14404
|
+
var features = this.circles.filter(function (circle) {
|
|
14405
|
+
var _circle$floorId;
|
|
14406
|
+
if (circle.hidden) return false;
|
|
14407
|
+
var circleFloor = (_circle$floorId = circle.floorId) !== null && _circle$floorId !== void 0 ? _circle$floorId : "";
|
|
14408
|
+
return circleFloor === floorId || isOutdoor && circleFloor === "";
|
|
14409
|
+
}).map(function (circle) {
|
|
14410
|
+
return {
|
|
14411
|
+
type: "Feature",
|
|
14412
|
+
properties: {
|
|
14413
|
+
id: circle.id,
|
|
14414
|
+
fillColor: circle.fillColor,
|
|
14415
|
+
fillOpacity: circle.fillOpacity,
|
|
14416
|
+
strokeColor: circle.strokeColor,
|
|
14417
|
+
strokeWidth: circle.strokeWidth,
|
|
14418
|
+
strokeOpacity: circle.strokeOpacity,
|
|
14419
|
+
renderOrder: circle.renderOrder
|
|
14420
|
+
},
|
|
14421
|
+
geometry: {
|
|
14422
|
+
type: "Polygon",
|
|
14423
|
+
coordinates: [circleRing(circle.coordinate.lng, circle.coordinate.lat, circle.radiusMeters)]
|
|
14424
|
+
}
|
|
14425
|
+
};
|
|
14426
|
+
});
|
|
14427
|
+
return {
|
|
14428
|
+
type: "FeatureCollection",
|
|
14429
|
+
features: features
|
|
14430
|
+
};
|
|
14431
|
+
}
|
|
14432
|
+
|
|
14433
|
+
/**
|
|
14434
|
+
* Idempotently adds the shared circle source and its fill/line layers.
|
|
14435
|
+
* Layers are inserted below the first symbol layer so place labels and
|
|
14436
|
+
* markers stay readable above the translucent fill. Safe to call at any
|
|
14437
|
+
* time: a style that is still loading simply rejects the calls, and the
|
|
14438
|
+
* styledata listener retries once the style is ready.
|
|
14439
|
+
*/
|
|
14440
|
+
/**
|
|
14441
|
+
* Resolves the layer id to insert circle layers before, for one render
|
|
14442
|
+
* order. `undefined` means "append on top".
|
|
14443
|
+
*
|
|
14444
|
+
* `aboveBasemap` finds the topmost non-symbol layer of the style and
|
|
14445
|
+
* inserts before the first symbol layer that follows it. On indoor styles
|
|
14446
|
+
* the floor-plate and building polygons are ordered after the first symbol
|
|
14447
|
+
* layer, so anchoring on the topmost geometry layer — instead of the first
|
|
14448
|
+
* symbol layer — guarantees circles are never occluded by basemap fills
|
|
14449
|
+
* while still rendering below the labels that follow them.
|
|
14450
|
+
*/
|
|
14451
|
+
}, {
|
|
14452
|
+
key: "circleBeforeIdFor",
|
|
14453
|
+
value: function circleBeforeIdFor(order) {
|
|
14454
|
+
var _this$map$getStyle$la2, _this$map$getStyle2, _layers$slice$find;
|
|
14455
|
+
if (order === "top") return undefined;
|
|
14456
|
+
var layers = ((_this$map$getStyle$la2 = (_this$map$getStyle2 = this.map.getStyle()) === null || _this$map$getStyle2 === void 0 ? void 0 : _this$map$getStyle2.layers) !== null && _this$map$getStyle$la2 !== void 0 ? _this$map$getStyle$la2 : []).filter(function (layer) {
|
|
14457
|
+
return !isCircleLayerId(layer.id);
|
|
14458
|
+
});
|
|
14459
|
+
if (order === "belowLabels") {
|
|
14460
|
+
var _layers$find;
|
|
14461
|
+
return (_layers$find = layers.find(function (layer) {
|
|
14462
|
+
return layer.type === "symbol";
|
|
14463
|
+
})) === null || _layers$find === void 0 ? void 0 : _layers$find.id;
|
|
14464
|
+
}
|
|
14465
|
+
|
|
14466
|
+
// aboveBasemap
|
|
14467
|
+
var lastNonSymbolIndex = -1;
|
|
14468
|
+
layers.forEach(function (layer, index) {
|
|
14469
|
+
if (layer.type !== "symbol") lastNonSymbolIndex = index;
|
|
14470
|
+
});
|
|
14471
|
+
return (_layers$slice$find = layers.slice(lastNonSymbolIndex + 1).find(function (layer) {
|
|
14472
|
+
return layer.type === "symbol";
|
|
14473
|
+
})) === null || _layers$slice$find === void 0 ? void 0 : _layers$slice$find.id;
|
|
14474
|
+
}
|
|
14475
|
+
|
|
14476
|
+
/**
|
|
14477
|
+
* Idempotently ensures the shared circle source and one fill/line layer
|
|
14478
|
+
* pair per render order in use, at the placement that order requires.
|
|
14479
|
+
* Placement is recomputed and re-asserted (via moveLayer) on every call,
|
|
14480
|
+
* so circles regain their correct z-order after any style reload or
|
|
14481
|
+
* floor/parent-place change. Safe to call at any time: a style that is
|
|
14482
|
+
* still loading simply rejects the calls, and the styledata listener
|
|
14483
|
+
* retries once the style is ready.
|
|
14484
|
+
*/
|
|
14485
|
+
}, {
|
|
14486
|
+
key: "ensureCircleLayers",
|
|
14487
|
+
value: function ensureCircleLayers() {
|
|
14488
|
+
if (!this.map) return;
|
|
14489
|
+
try {
|
|
14490
|
+
if (!this.map.getSource(CIRCLE_SOURCE_ID)) {
|
|
14491
|
+
this.map.addSource(CIRCLE_SOURCE_ID, {
|
|
14492
|
+
type: "geojson",
|
|
14493
|
+
data: this.circleFeatureCollection()
|
|
14494
|
+
});
|
|
14495
|
+
}
|
|
14496
|
+
var ordersInUse = new Set(this.circles.map(function (c) {
|
|
14497
|
+
return c.renderOrder;
|
|
14498
|
+
}));
|
|
14499
|
+
// Always keep the default bucket alive so an empty map still renders
|
|
14500
|
+
// newly added circles without a layer rebuild
|
|
14501
|
+
ordersInUse.add("aboveBasemap");
|
|
14502
|
+
var _iterator = map_createForOfIteratorHelper(ordersInUse),
|
|
14503
|
+
_step;
|
|
14504
|
+
try {
|
|
14505
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
14506
|
+
var order = _step.value;
|
|
14507
|
+
var ids = circleLayerIdsFor(order);
|
|
14508
|
+
var beforeId = this.circleBeforeIdFor(order);
|
|
14509
|
+
var orderFilter = ["==", ["get", "renderOrder"], order];
|
|
14510
|
+
if (!this.map.getLayer(ids.fill)) {
|
|
14511
|
+
var fillLayer = {
|
|
14512
|
+
id: ids.fill,
|
|
14513
|
+
type: "fill",
|
|
14514
|
+
source: CIRCLE_SOURCE_ID,
|
|
14515
|
+
filter: orderFilter,
|
|
14516
|
+
paint: {
|
|
14517
|
+
"fill-color": ["get", "fillColor"],
|
|
14518
|
+
"fill-opacity": ["get", "fillOpacity"]
|
|
14519
|
+
}
|
|
14520
|
+
};
|
|
14521
|
+
this.map.addLayer(fillLayer, beforeId);
|
|
14522
|
+
} else {
|
|
14523
|
+
this.map.moveLayer(ids.fill, beforeId);
|
|
14524
|
+
}
|
|
14525
|
+
if (!this.map.getLayer(ids.line)) {
|
|
14526
|
+
var lineLayer = {
|
|
14527
|
+
id: ids.line,
|
|
14528
|
+
type: "line",
|
|
14529
|
+
source: CIRCLE_SOURCE_ID,
|
|
14530
|
+
filter: orderFilter,
|
|
14531
|
+
paint: {
|
|
14532
|
+
"line-color": ["get", "strokeColor"],
|
|
14533
|
+
"line-width": ["get", "strokeWidth"],
|
|
14534
|
+
"line-opacity": ["get", "strokeOpacity"]
|
|
14535
|
+
}
|
|
14536
|
+
};
|
|
14537
|
+
this.map.addLayer(lineLayer, beforeId);
|
|
14538
|
+
} else {
|
|
14539
|
+
this.map.moveLayer(ids.line, beforeId);
|
|
14540
|
+
}
|
|
14541
|
+
}
|
|
14542
|
+
} catch (err) {
|
|
14543
|
+
_iterator.e(err);
|
|
14544
|
+
} finally {
|
|
14545
|
+
_iterator.f();
|
|
14546
|
+
}
|
|
14547
|
+
} catch (error) {
|
|
14548
|
+
// Style may not be loaded yet; the styledata listener re-adds the layers
|
|
14549
|
+
}
|
|
14550
|
+
}
|
|
14551
|
+
|
|
14552
|
+
/**
|
|
14553
|
+
* Re-renders all circles: ensures the source and layers exist, then pushes
|
|
14554
|
+
* the current FeatureCollection. Called after every mutation of the circle
|
|
14555
|
+
* list, on floor changes, and when the map style reloads.
|
|
14556
|
+
*/
|
|
14557
|
+
}, {
|
|
14558
|
+
key: "refreshCircles",
|
|
14559
|
+
value: function refreshCircles() {
|
|
14560
|
+
if (!this.map) return;
|
|
14561
|
+
if (this.circles.length === 0 && !this.map.getSource(CIRCLE_SOURCE_ID)) return;
|
|
14562
|
+
this.ensureCircleLayers();
|
|
14563
|
+
try {
|
|
14564
|
+
var source = this.map.getSource(CIRCLE_SOURCE_ID);
|
|
14565
|
+
source === null || source === void 0 || source.setData(this.circleFeatureCollection());
|
|
14566
|
+
} catch (error) {
|
|
14567
|
+
// Source may not exist while a new style is loading
|
|
14568
|
+
}
|
|
14569
|
+
}
|
|
13887
14570
|
|
|
13888
14571
|
/**
|
|
13889
14572
|
* Use it to change the current layer
|
|
@@ -13903,6 +14586,7 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
13903
14586
|
}
|
|
13904
14587
|
this.updateFiltersTo(floorKeyString);
|
|
13905
14588
|
this.updateMarkersTo(floorKeyString);
|
|
14589
|
+
this.refreshCircles();
|
|
13906
14590
|
this.routeController.updateRouteLayers(floorKeyString);
|
|
13907
14591
|
this.routeController.updateRouteMarkerVisibility(floorKeyString);
|
|
13908
14592
|
}
|
|
@@ -13914,12 +14598,12 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
13914
14598
|
}, {
|
|
13915
14599
|
key: "updateMarkersTo",
|
|
13916
14600
|
value: function updateMarkersTo(floorId) {
|
|
13917
|
-
var _this$innerFloors$
|
|
13918
|
-
_this$innerFloors$
|
|
14601
|
+
var _this$innerFloors$fin8,
|
|
14602
|
+
_this$innerFloors$fin9,
|
|
13919
14603
|
_this1 = this;
|
|
13920
|
-
var isOutdoor = !this.parentPlace || ((_this$innerFloors$
|
|
14604
|
+
var isOutdoor = !this.parentPlace || ((_this$innerFloors$fin8 = (_this$innerFloors$fin9 = this.innerFloors.find(function (floor) {
|
|
13921
14605
|
return floor.key === floorId;
|
|
13922
|
-
})) === null || _this$innerFloors$
|
|
14606
|
+
})) === null || _this$innerFloors$fin9 === void 0 ? void 0 : _this$innerFloors$fin9.reachableFromGPS) !== null && _this$innerFloors$fin8 !== void 0 ? _this$innerFloors$fin8 : false);
|
|
13923
14607
|
this.markers.forEach(function (e) {
|
|
13924
14608
|
e.changeFloor(floorId, _this1.map, isOutdoor);
|
|
13925
14609
|
});
|
|
@@ -13927,20 +14611,20 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
13927
14611
|
}, {
|
|
13928
14612
|
key: "updateFiltersTo",
|
|
13929
14613
|
value: function updateFiltersTo(floorId) {
|
|
13930
|
-
var _this$map$getStyle$
|
|
13931
|
-
_this$map$
|
|
14614
|
+
var _this$map$getStyle$la3,
|
|
14615
|
+
_this$map$getStyle3,
|
|
13932
14616
|
_this10 = this,
|
|
13933
|
-
_this$innerFloors$
|
|
14617
|
+
_this$innerFloors$fin0;
|
|
13934
14618
|
if (!this.map) return;
|
|
13935
|
-
var layers = (_this$map$getStyle$
|
|
14619
|
+
var layers = (_this$map$getStyle$la3 = (_this$map$getStyle3 = this.map.getStyle()) === null || _this$map$getStyle3 === void 0 ? void 0 : _this$map$getStyle3.layers) !== null && _this$map$getStyle$la3 !== void 0 ? _this$map$getStyle$la3 : [];
|
|
13936
14620
|
layers.filter(function (l) {
|
|
13937
14621
|
return l.id.startsWith("base-indoor-");
|
|
13938
14622
|
}).forEach(function (l) {
|
|
13939
14623
|
_this10.map.removeLayer(l.id);
|
|
13940
14624
|
});
|
|
13941
|
-
var baseFloorId = (_this$innerFloors$
|
|
14625
|
+
var baseFloorId = (_this$innerFloors$fin0 = this.innerFloors.find(function (floor) {
|
|
13942
14626
|
return floor.key === floorId;
|
|
13943
|
-
})) === null || _this$innerFloors$
|
|
14627
|
+
})) === null || _this$innerFloors$fin0 === void 0 ? void 0 : _this$innerFloors$fin0.baseFloor;
|
|
13944
14628
|
var indoorLayers = layers.filter(function (layer) {
|
|
13945
14629
|
return layer.id.startsWith("indoor-");
|
|
13946
14630
|
});
|
|
@@ -14059,11 +14743,11 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
14059
14743
|
var minLng;
|
|
14060
14744
|
var maxLat;
|
|
14061
14745
|
var maxLng;
|
|
14062
|
-
var
|
|
14063
|
-
|
|
14746
|
+
var _iterator2 = map_createForOfIteratorHelper(coordinates),
|
|
14747
|
+
_step2;
|
|
14064
14748
|
try {
|
|
14065
|
-
for (
|
|
14066
|
-
var _coord =
|
|
14749
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
14750
|
+
var _coord = _step2.value;
|
|
14067
14751
|
var lat = _coord.lat,
|
|
14068
14752
|
lng = _coord.lng;
|
|
14069
14753
|
minLat = minLat === undefined ? lat : Math.min(minLat, lat);
|
|
@@ -14072,9 +14756,9 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
14072
14756
|
maxLng = maxLng === undefined ? lng : Math.max(maxLng, lng);
|
|
14073
14757
|
}
|
|
14074
14758
|
} catch (err) {
|
|
14075
|
-
|
|
14759
|
+
_iterator2.e(err);
|
|
14076
14760
|
} finally {
|
|
14077
|
-
|
|
14761
|
+
_iterator2.f();
|
|
14078
14762
|
}
|
|
14079
14763
|
var bounds = [minLng !== null && minLng !== void 0 ? minLng : 0, minLat !== null && minLat !== void 0 ? minLat : 0, maxLng !== null && maxLng !== void 0 ? maxLng : 0, maxLat !== null && maxLat !== void 0 ? maxLat : 0];
|
|
14080
14764
|
|
|
@@ -14279,7 +14963,7 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
14279
14963
|
var _this11 = this;
|
|
14280
14964
|
this.map.on("click", /*#__PURE__*/function () {
|
|
14281
14965
|
var _ref4 = map_asyncToGenerator(/*#__PURE__*/map_regenerator().m(function _callee2(e) {
|
|
14282
|
-
var features, roomFeatures, touchedFeature, ref, _clickedPlace, _ref5, _clickedPlace$mapvxId, _clickedPlace2, _clickedPlace3, clickedPlace,
|
|
14966
|
+
var features, roomFeatures, touchedFeature, ref, _clickedPlace, _ref5, _clickedPlace$mapvxId, _clickedPlace2, _clickedPlace3, clickedPlace, _iterator3, _step3, potentialParentPlace, cachedSubPlaces, cachedPlaces, clickedPlaceId, _t2;
|
|
14283
14967
|
return map_regenerator().w(function (_context2) {
|
|
14284
14968
|
while (1) switch (_context2.p = _context2.n) {
|
|
14285
14969
|
case 0:
|
|
@@ -14304,15 +14988,15 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
14304
14988
|
_context2.n = 7;
|
|
14305
14989
|
break;
|
|
14306
14990
|
}
|
|
14307
|
-
|
|
14991
|
+
_iterator3 = map_createForOfIteratorHelper(_this11.potentialParentPlaces);
|
|
14308
14992
|
_context2.p = 1;
|
|
14309
|
-
|
|
14993
|
+
_iterator3.s();
|
|
14310
14994
|
case 2:
|
|
14311
|
-
if ((
|
|
14995
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
14312
14996
|
_context2.n = 4;
|
|
14313
14997
|
break;
|
|
14314
14998
|
}
|
|
14315
|
-
potentialParentPlace =
|
|
14999
|
+
potentialParentPlace = _step3.value;
|
|
14316
15000
|
cachedSubPlaces = _this11.repository.getCachedSubPlaces(potentialParentPlace.mapvxId);
|
|
14317
15001
|
if (!cachedSubPlaces) {
|
|
14318
15002
|
_context2.n = 3;
|
|
@@ -14335,10 +15019,10 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
14335
15019
|
case 5:
|
|
14336
15020
|
_context2.p = 5;
|
|
14337
15021
|
_t2 = _context2.v;
|
|
14338
|
-
|
|
15022
|
+
_iterator3.e(_t2);
|
|
14339
15023
|
case 6:
|
|
14340
15024
|
_context2.p = 6;
|
|
14341
|
-
|
|
15025
|
+
_iterator3.f();
|
|
14342
15026
|
return _context2.f(6);
|
|
14343
15027
|
case 7:
|
|
14344
15028
|
if (!(clickedPlace === undefined)) {
|
|
@@ -14457,7 +15141,7 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
14457
15141
|
filter: ["all", ["has", "ref"], ["==", ["get", "ref"], "unselected"]],
|
|
14458
15142
|
paint: {
|
|
14459
15143
|
"fill-extrusion-height": 2.5,
|
|
14460
|
-
"fill-extrusion-color":
|
|
15144
|
+
"fill-extrusion-color": MAPVX_BRAND_COLOR,
|
|
14461
15145
|
"fill-extrusion-opacity": 0.8
|
|
14462
15146
|
}
|
|
14463
15147
|
};
|
|
@@ -14470,7 +15154,7 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
14470
15154
|
"source-layer": "area",
|
|
14471
15155
|
filter: ["all", ["has", "ref"], ["==", ["get", "ref"], "unselected"]],
|
|
14472
15156
|
paint: {
|
|
14473
|
-
"fill-color":
|
|
15157
|
+
"fill-color": MAPVX_BRAND_COLOR
|
|
14474
15158
|
}
|
|
14475
15159
|
};
|
|
14476
15160
|
this.map.addLayer(_layer);
|
|
@@ -14479,10 +15163,10 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
14479
15163
|
}, {
|
|
14480
15164
|
key: "createBasicFilters",
|
|
14481
15165
|
value: function createBasicFilters() {
|
|
14482
|
-
var _this$parentPlaceId3, _this$
|
|
15166
|
+
var _this$parentPlaceId3, _this$currentFloor4;
|
|
14483
15167
|
var publicPlaceFilter = ["==", ["get", "public_place"], true];
|
|
14484
15168
|
var subPlaceFilter = ["!", ["in", (_this$parentPlaceId3 = this.parentPlaceId) !== null && _this$parentPlaceId3 !== void 0 ? _this$parentPlaceId3 : "noRef", ["get", "is_subplace"]]];
|
|
14485
|
-
var floorId = (_this$
|
|
15169
|
+
var floorId = (_this$currentFloor4 = this.currentFloor) !== null && _this$currentFloor4 !== void 0 ? _this$currentFloor4 : "noRef";
|
|
14486
15170
|
var floorFilter = ["in", floorId, ["get", "floor_key"]];
|
|
14487
15171
|
var showInFloorFilter = ["in", floorId, ["get", "show_in_floor"]];
|
|
14488
15172
|
var basicFilters = publicPlaceFilter;
|
|
@@ -14864,7 +15548,7 @@ var InternalMapVXMap = /*#__PURE__*/function (_Loggeable) {
|
|
|
14864
15548
|
"source-layer": "area",
|
|
14865
15549
|
filter: ["all", ["has", "ref"], ["==", ["get", "ref"], "unselected"]],
|
|
14866
15550
|
paint: {
|
|
14867
|
-
"line-color":
|
|
15551
|
+
"line-color": MAPVX_BRAND_COLOR,
|
|
14868
15552
|
"line-width": 4
|
|
14869
15553
|
}
|
|
14870
15554
|
};
|
|
@@ -17248,6 +17932,8 @@ function normalizeOrigin(raw) {
|
|
|
17248
17932
|
|
|
17249
17933
|
// ─── Domain Models: Categories ───────────────────────────────────────────────
|
|
17250
17934
|
|
|
17935
|
+
// ─── Domain Models: Circle ───────────────────────────────────────────────────
|
|
17936
|
+
|
|
17251
17937
|
|
|
17252
17938
|
// ─── Domain Models: City Filter ──────────────────────────────────────────────
|
|
17253
17939
|
|