@mapvx/web-js 1.0.0
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/LICENSE.md +19 -0
- package/README.md +257 -0
- package/dist/cjs/assets/icons.js +87 -0
- package/dist/cjs/assets/icons.js.map +1 -0
- package/dist/cjs/assets/route_animation_icon.svg +15 -0
- package/dist/cjs/assets/user-dot-icon.svg +3 -0
- package/dist/cjs/config/sdkConfig.js +3 -0
- package/dist/cjs/config/sdkConfig.js.map +1 -0
- package/dist/cjs/controllers/routeController.js +1054 -0
- package/dist/cjs/controllers/routeController.js.map +1 -0
- package/dist/cjs/domain/models/_internal.js +15 -0
- package/dist/cjs/domain/models/_internal.js.map +1 -0
- package/dist/cjs/domain/models/_rtl.js +10 -0
- package/dist/cjs/domain/models/_rtl.js.map +1 -0
- package/dist/cjs/domain/models/animation.js +63 -0
- package/dist/cjs/domain/models/animation.js.map +1 -0
- package/dist/cjs/domain/models/banner.js +24 -0
- package/dist/cjs/domain/models/banner.js.map +1 -0
- package/dist/cjs/domain/models/categories.js +25 -0
- package/dist/cjs/domain/models/categories.js.map +1 -0
- package/dist/cjs/domain/models/cityFilterOption.js +3 -0
- package/dist/cjs/domain/models/cityFilterOption.js.map +1 -0
- package/dist/cjs/domain/models/configuration.js +3 -0
- package/dist/cjs/domain/models/configuration.js.map +1 -0
- package/dist/cjs/domain/models/cssCustomization.js +3 -0
- package/dist/cjs/domain/models/cssCustomization.js.map +1 -0
- package/dist/cjs/domain/models/fitOptions.js +3 -0
- package/dist/cjs/domain/models/fitOptions.js.map +1 -0
- package/dist/cjs/domain/models/innerFloors.js +3 -0
- package/dist/cjs/domain/models/innerFloors.js.map +1 -0
- package/dist/cjs/domain/models/institution.js +44 -0
- package/dist/cjs/domain/models/institution.js.map +1 -0
- package/dist/cjs/domain/models/latLng.js +3 -0
- package/dist/cjs/domain/models/latLng.js.map +1 -0
- package/dist/cjs/domain/models/location.js +3 -0
- package/dist/cjs/domain/models/location.js.map +1 -0
- package/dist/cjs/domain/models/loggeable.js +52 -0
- package/dist/cjs/domain/models/loggeable.js.map +1 -0
- package/dist/cjs/domain/models/mapCamera.js +3 -0
- package/dist/cjs/domain/models/mapCamera.js.map +1 -0
- package/dist/cjs/domain/models/mapConfig.js +15 -0
- package/dist/cjs/domain/models/mapConfig.js.map +1 -0
- package/dist/cjs/domain/models/marker.js +400 -0
- package/dist/cjs/domain/models/marker.js.map +1 -0
- package/dist/cjs/domain/models/multilanguage.js +18 -0
- package/dist/cjs/domain/models/multilanguage.js.map +1 -0
- package/dist/cjs/domain/models/openingHours.js +3 -0
- package/dist/cjs/domain/models/openingHours.js.map +1 -0
- package/dist/cjs/domain/models/place.js +101 -0
- package/dist/cjs/domain/models/place.js.map +1 -0
- package/dist/cjs/domain/models/platform.js +3 -0
- package/dist/cjs/domain/models/platform.js.map +1 -0
- package/dist/cjs/domain/models/popover.js +3 -0
- package/dist/cjs/domain/models/popover.js.map +1 -0
- package/dist/cjs/domain/models/product.js +3 -0
- package/dist/cjs/domain/models/product.js.map +1 -0
- package/dist/cjs/domain/models/property.js +104 -0
- package/dist/cjs/domain/models/property.js.map +1 -0
- package/dist/cjs/domain/models/route.js +166 -0
- package/dist/cjs/domain/models/route.js.map +1 -0
- package/dist/cjs/domain/models/routeConfiguration.js +80 -0
- package/dist/cjs/domain/models/routeConfiguration.js.map +1 -0
- package/dist/cjs/domain/models/routeInstance.js +30 -0
- package/dist/cjs/domain/models/routeInstance.js.map +1 -0
- package/dist/cjs/domain/models/routeStyle.js +3 -0
- package/dist/cjs/domain/models/routeStyle.js.map +1 -0
- package/dist/cjs/domain/models/transport.js +22 -0
- package/dist/cjs/domain/models/transport.js.map +1 -0
- package/dist/cjs/domain/ports/ICache.js +3 -0
- package/dist/cjs/domain/ports/ICache.js.map +1 -0
- package/dist/cjs/domain/ports/IHttpClient.js +3 -0
- package/dist/cjs/domain/ports/IHttpClient.js.map +1 -0
- package/dist/cjs/domain/ports/ILogger.js +23 -0
- package/dist/cjs/domain/ports/ILogger.js.map +1 -0
- package/dist/cjs/domain/ports/index.js +10 -0
- package/dist/cjs/domain/ports/index.js.map +1 -0
- package/dist/cjs/index.js +76 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/infrastructure/cache/CacheManager.js +236 -0
- package/dist/cjs/infrastructure/cache/CacheManager.js.map +1 -0
- package/dist/cjs/infrastructure/cache/LRUCache.js +153 -0
- package/dist/cjs/infrastructure/cache/LRUCache.js.map +1 -0
- package/dist/cjs/infrastructure/cache/PersistentCache.js +160 -0
- package/dist/cjs/infrastructure/cache/PersistentCache.js.map +1 -0
- package/dist/cjs/infrastructure/cache/cacheConfig.js +70 -0
- package/dist/cjs/infrastructure/cache/cacheConfig.js.map +1 -0
- package/dist/cjs/infrastructure/http/FetchHttpClient.js +75 -0
- package/dist/cjs/infrastructure/http/FetchHttpClient.js.map +1 -0
- package/dist/cjs/infrastructure/logging/CountlyLogger.js +78 -0
- package/dist/cjs/infrastructure/logging/CountlyLogger.js.map +1 -0
- package/dist/cjs/interfaces/cache.js +3 -0
- package/dist/cjs/interfaces/cache.js.map +1 -0
- package/dist/cjs/interfaces/healthResponse.js +3 -0
- package/dist/cjs/interfaces/healthResponse.js.map +1 -0
- package/dist/cjs/interfaces/institutionResponse.js +3 -0
- package/dist/cjs/interfaces/institutionResponse.js.map +1 -0
- package/dist/cjs/interfaces/metadata.js +3 -0
- package/dist/cjs/interfaces/metadata.js.map +1 -0
- package/dist/cjs/interfaces/placeResponse.js +3 -0
- package/dist/cjs/interfaces/placeResponse.js.map +1 -0
- package/dist/cjs/interfaces/routeCacheResponse.js +3 -0
- package/dist/cjs/interfaces/routeCacheResponse.js.map +1 -0
- package/dist/cjs/interfaces/routeResponse.js +3 -0
- package/dist/cjs/interfaces/routeResponse.js.map +1 -0
- package/dist/cjs/interfaces/styleResponse.js +3 -0
- package/dist/cjs/interfaces/styleResponse.js.map +1 -0
- package/dist/cjs/logger/logger.js +91 -0
- package/dist/cjs/logger/logger.js.map +1 -0
- package/dist/cjs/logger/rollbar.js +24 -0
- package/dist/cjs/logger/rollbar.js.map +1 -0
- package/dist/cjs/map/map.js +1457 -0
- package/dist/cjs/map/map.js.map +1 -0
- package/dist/cjs/repository/repository.js +574 -0
- package/dist/cjs/repository/repository.js.map +1 -0
- package/dist/cjs/repository/requester.js +590 -0
- package/dist/cjs/repository/requester.js.map +1 -0
- package/dist/cjs/sdk.js +351 -0
- package/dist/cjs/sdk.js.map +1 -0
- package/dist/cjs/utils/error.js +20 -0
- package/dist/cjs/utils/error.js.map +1 -0
- package/dist/cjs/utils/images.js +26 -0
- package/dist/cjs/utils/images.js.map +1 -0
- package/dist/cjs/utils/nav-functions.js +150 -0
- package/dist/cjs/utils/nav-functions.js.map +1 -0
- package/dist/cjs/utils/opening-hours-helper.js +911 -0
- package/dist/cjs/utils/opening-hours-helper.js.map +1 -0
- package/dist/cjs/utils/route-utils.js +58 -0
- package/dist/cjs/utils/route-utils.js.map +1 -0
- package/dist/cjs/utils/update-css.js +77 -0
- package/dist/cjs/utils/update-css.js.map +1 -0
- package/dist/cjs/utils/utils.js +105 -0
- package/dist/cjs/utils/utils.js.map +1 -0
- package/dist/es/assets/icons.d.ts +86 -0
- package/dist/es/assets/icons.d.ts.map +1 -0
- package/dist/es/assets/icons.js +83 -0
- package/dist/es/assets/icons.js.map +1 -0
- package/dist/es/assets/route_animation_icon.svg +15 -0
- package/dist/es/assets/user-dot-icon.svg +3 -0
- package/dist/es/config/sdkConfig.d.ts +105 -0
- package/dist/es/config/sdkConfig.d.ts.map +1 -0
- package/dist/es/config/sdkConfig.js +2 -0
- package/dist/es/config/sdkConfig.js.map +1 -0
- package/dist/es/controllers/routeController.d.ts +161 -0
- package/dist/es/controllers/routeController.d.ts.map +1 -0
- package/dist/es/controllers/routeController.js +1050 -0
- package/dist/es/controllers/routeController.js.map +1 -0
- package/dist/es/domain/models/_internal.d.ts +21 -0
- package/dist/es/domain/models/_internal.d.ts.map +1 -0
- package/dist/es/domain/models/_internal.js +11 -0
- package/dist/es/domain/models/_internal.js.map +1 -0
- package/dist/es/domain/models/_rtl.d.ts +7 -0
- package/dist/es/domain/models/_rtl.d.ts.map +1 -0
- package/dist/es/domain/models/_rtl.js +7 -0
- package/dist/es/domain/models/_rtl.js.map +1 -0
- package/dist/es/domain/models/animation.d.ts +161 -0
- package/dist/es/domain/models/animation.d.ts.map +1 -0
- package/dist/es/domain/models/animation.js +58 -0
- package/dist/es/domain/models/animation.js.map +1 -0
- package/dist/es/domain/models/banner.d.ts +64 -0
- package/dist/es/domain/models/banner.d.ts.map +1 -0
- package/dist/es/domain/models/banner.js +20 -0
- package/dist/es/domain/models/banner.js.map +1 -0
- package/dist/es/domain/models/categories.d.ts +157 -0
- package/dist/es/domain/models/categories.d.ts.map +1 -0
- package/dist/es/domain/models/categories.js +20 -0
- package/dist/es/domain/models/categories.js.map +1 -0
- package/dist/es/domain/models/cityFilterOption.d.ts +15 -0
- package/dist/es/domain/models/cityFilterOption.d.ts.map +1 -0
- package/dist/es/domain/models/cityFilterOption.js +2 -0
- package/dist/es/domain/models/cityFilterOption.js.map +1 -0
- package/dist/es/domain/models/configuration.d.ts +523 -0
- package/dist/es/domain/models/configuration.d.ts.map +1 -0
- package/dist/es/domain/models/configuration.js +2 -0
- package/dist/es/domain/models/configuration.js.map +1 -0
- package/dist/es/domain/models/cssCustomization.d.ts +63 -0
- package/dist/es/domain/models/cssCustomization.d.ts.map +1 -0
- package/dist/es/domain/models/cssCustomization.js +2 -0
- package/dist/es/domain/models/cssCustomization.js.map +1 -0
- package/dist/es/domain/models/fitOptions.d.ts +175 -0
- package/dist/es/domain/models/fitOptions.d.ts.map +1 -0
- package/dist/es/domain/models/fitOptions.js +2 -0
- package/dist/es/domain/models/fitOptions.js.map +1 -0
- package/dist/es/domain/models/innerFloors.d.ts +42 -0
- package/dist/es/domain/models/innerFloors.d.ts.map +1 -0
- package/dist/es/domain/models/innerFloors.js +2 -0
- package/dist/es/domain/models/innerFloors.js.map +1 -0
- package/dist/es/domain/models/institution.d.ts +64 -0
- package/dist/es/domain/models/institution.d.ts.map +1 -0
- package/dist/es/domain/models/institution.js +40 -0
- package/dist/es/domain/models/institution.js.map +1 -0
- package/dist/es/domain/models/latLng.d.ts +14 -0
- package/dist/es/domain/models/latLng.d.ts.map +1 -0
- package/dist/es/domain/models/latLng.js +2 -0
- package/dist/es/domain/models/latLng.js.map +1 -0
- package/dist/es/domain/models/location.d.ts +10 -0
- package/dist/es/domain/models/location.d.ts.map +1 -0
- package/dist/es/domain/models/location.js +2 -0
- package/dist/es/domain/models/location.js.map +1 -0
- package/dist/es/domain/models/loggeable.d.ts +43 -0
- package/dist/es/domain/models/loggeable.d.ts.map +1 -0
- package/dist/es/domain/models/loggeable.js +48 -0
- package/dist/es/domain/models/loggeable.js.map +1 -0
- package/dist/es/domain/models/mapCamera.d.ts +109 -0
- package/dist/es/domain/models/mapCamera.d.ts.map +1 -0
- package/dist/es/domain/models/mapCamera.js +2 -0
- package/dist/es/domain/models/mapCamera.js.map +1 -0
- package/dist/es/domain/models/mapConfig.d.ts +238 -0
- package/dist/es/domain/models/mapConfig.d.ts.map +1 -0
- package/dist/es/domain/models/mapConfig.js +12 -0
- package/dist/es/domain/models/mapConfig.js.map +1 -0
- package/dist/es/domain/models/marker.d.ts +301 -0
- package/dist/es/domain/models/marker.d.ts.map +1 -0
- package/dist/es/domain/models/marker.js +396 -0
- package/dist/es/domain/models/marker.js.map +1 -0
- package/dist/es/domain/models/multilanguage.d.ts +27 -0
- package/dist/es/domain/models/multilanguage.d.ts.map +1 -0
- package/dist/es/domain/models/multilanguage.js +14 -0
- package/dist/es/domain/models/multilanguage.js.map +1 -0
- package/dist/es/domain/models/openingHours.d.ts +30 -0
- package/dist/es/domain/models/openingHours.d.ts.map +1 -0
- package/dist/es/domain/models/openingHours.js +2 -0
- package/dist/es/domain/models/openingHours.js.map +1 -0
- package/dist/es/domain/models/place.d.ts +167 -0
- package/dist/es/domain/models/place.d.ts.map +1 -0
- package/dist/es/domain/models/place.js +97 -0
- package/dist/es/domain/models/place.js.map +1 -0
- package/dist/es/domain/models/platform.d.ts +6 -0
- package/dist/es/domain/models/platform.d.ts.map +1 -0
- package/dist/es/domain/models/platform.js +2 -0
- package/dist/es/domain/models/platform.js.map +1 -0
- package/dist/es/domain/models/popover.d.ts +14 -0
- package/dist/es/domain/models/popover.d.ts.map +1 -0
- package/dist/es/domain/models/popover.js +2 -0
- package/dist/es/domain/models/popover.js.map +1 -0
- package/dist/es/domain/models/product.d.ts +36 -0
- package/dist/es/domain/models/product.d.ts.map +1 -0
- package/dist/es/domain/models/product.js +2 -0
- package/dist/es/domain/models/product.js.map +1 -0
- package/dist/es/domain/models/property.d.ts +172 -0
- package/dist/es/domain/models/property.d.ts.map +1 -0
- package/dist/es/domain/models/property.js +100 -0
- package/dist/es/domain/models/property.js.map +1 -0
- package/dist/es/domain/models/route.d.ts +199 -0
- package/dist/es/domain/models/route.d.ts.map +1 -0
- package/dist/es/domain/models/route.js +160 -0
- package/dist/es/domain/models/route.js.map +1 -0
- package/dist/es/domain/models/routeConfiguration.d.ts +140 -0
- package/dist/es/domain/models/routeConfiguration.d.ts.map +1 -0
- package/dist/es/domain/models/routeConfiguration.js +75 -0
- package/dist/es/domain/models/routeConfiguration.js.map +1 -0
- package/dist/es/domain/models/routeInstance.d.ts +52 -0
- package/dist/es/domain/models/routeInstance.d.ts.map +1 -0
- package/dist/es/domain/models/routeInstance.js +26 -0
- package/dist/es/domain/models/routeInstance.js.map +1 -0
- package/dist/es/domain/models/routeStyle.d.ts +47 -0
- package/dist/es/domain/models/routeStyle.d.ts.map +1 -0
- package/dist/es/domain/models/routeStyle.js +2 -0
- package/dist/es/domain/models/routeStyle.js.map +1 -0
- package/dist/es/domain/models/transport.d.ts +176 -0
- package/dist/es/domain/models/transport.d.ts.map +1 -0
- package/dist/es/domain/models/transport.js +18 -0
- package/dist/es/domain/models/transport.js.map +1 -0
- package/dist/es/domain/ports/ICache.d.ts +70 -0
- package/dist/es/domain/ports/ICache.d.ts.map +1 -0
- package/dist/es/domain/ports/ICache.js +2 -0
- package/dist/es/domain/ports/ICache.js.map +1 -0
- package/dist/es/domain/ports/IHttpClient.d.ts +77 -0
- package/dist/es/domain/ports/IHttpClient.d.ts.map +1 -0
- package/dist/es/domain/ports/IHttpClient.js +2 -0
- package/dist/es/domain/ports/IHttpClient.js.map +1 -0
- package/dist/es/domain/ports/ILogger.d.ts +61 -0
- package/dist/es/domain/ports/ILogger.d.ts.map +1 -0
- package/dist/es/domain/ports/ILogger.js +19 -0
- package/dist/es/domain/ports/ILogger.js.map +1 -0
- package/dist/es/domain/ports/index.d.ts +9 -0
- package/dist/es/domain/ports/index.d.ts.map +1 -0
- package/dist/es/domain/ports/index.js +6 -0
- package/dist/es/domain/ports/index.js.map +1 -0
- package/dist/es/index.d.ts +58 -0
- package/dist/es/index.d.ts.map +1 -0
- package/dist/es/index.js +48 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/infrastructure/cache/CacheManager.d.ts +106 -0
- package/dist/es/infrastructure/cache/CacheManager.d.ts.map +1 -0
- package/dist/es/infrastructure/cache/CacheManager.js +232 -0
- package/dist/es/infrastructure/cache/CacheManager.js.map +1 -0
- package/dist/es/infrastructure/cache/LRUCache.d.ts +70 -0
- package/dist/es/infrastructure/cache/LRUCache.d.ts.map +1 -0
- package/dist/es/infrastructure/cache/LRUCache.js +149 -0
- package/dist/es/infrastructure/cache/LRUCache.js.map +1 -0
- package/dist/es/infrastructure/cache/PersistentCache.d.ts +58 -0
- package/dist/es/infrastructure/cache/PersistentCache.d.ts.map +1 -0
- package/dist/es/infrastructure/cache/PersistentCache.js +156 -0
- package/dist/es/infrastructure/cache/PersistentCache.js.map +1 -0
- package/dist/es/infrastructure/cache/cacheConfig.d.ts +51 -0
- package/dist/es/infrastructure/cache/cacheConfig.d.ts.map +1 -0
- package/dist/es/infrastructure/cache/cacheConfig.js +66 -0
- package/dist/es/infrastructure/cache/cacheConfig.js.map +1 -0
- package/dist/es/infrastructure/http/FetchHttpClient.d.ts +41 -0
- package/dist/es/infrastructure/http/FetchHttpClient.d.ts.map +1 -0
- package/dist/es/infrastructure/http/FetchHttpClient.js +71 -0
- package/dist/es/infrastructure/http/FetchHttpClient.js.map +1 -0
- package/dist/es/infrastructure/logging/CountlyLogger.d.ts +47 -0
- package/dist/es/infrastructure/logging/CountlyLogger.d.ts.map +1 -0
- package/dist/es/infrastructure/logging/CountlyLogger.js +74 -0
- package/dist/es/infrastructure/logging/CountlyLogger.js.map +1 -0
- package/dist/es/interfaces/cache.d.ts +5 -0
- package/dist/es/interfaces/cache.d.ts.map +1 -0
- package/dist/es/interfaces/cache.js +2 -0
- package/dist/es/interfaces/cache.js.map +1 -0
- package/dist/es/interfaces/healthResponse.d.ts +17 -0
- package/dist/es/interfaces/healthResponse.d.ts.map +1 -0
- package/dist/es/interfaces/healthResponse.js +2 -0
- package/dist/es/interfaces/healthResponse.js.map +1 -0
- package/dist/es/interfaces/institutionResponse.d.ts +12 -0
- package/dist/es/interfaces/institutionResponse.d.ts.map +1 -0
- package/dist/es/interfaces/institutionResponse.js +2 -0
- package/dist/es/interfaces/institutionResponse.js.map +1 -0
- package/dist/es/interfaces/metadata.d.ts +7 -0
- package/dist/es/interfaces/metadata.d.ts.map +1 -0
- package/dist/es/interfaces/metadata.js +2 -0
- package/dist/es/interfaces/metadata.js.map +1 -0
- package/dist/es/interfaces/placeResponse.d.ts +50 -0
- package/dist/es/interfaces/placeResponse.d.ts.map +1 -0
- package/dist/es/interfaces/placeResponse.js +2 -0
- package/dist/es/interfaces/placeResponse.js.map +1 -0
- package/dist/es/interfaces/routeCacheResponse.d.ts +13 -0
- package/dist/es/interfaces/routeCacheResponse.d.ts.map +1 -0
- package/dist/es/interfaces/routeCacheResponse.js +2 -0
- package/dist/es/interfaces/routeCacheResponse.js.map +1 -0
- package/dist/es/interfaces/routeResponse.d.ts +42 -0
- package/dist/es/interfaces/routeResponse.d.ts.map +1 -0
- package/dist/es/interfaces/routeResponse.js +2 -0
- package/dist/es/interfaces/routeResponse.js.map +1 -0
- package/dist/es/interfaces/styleResponse.d.ts +5 -0
- package/dist/es/interfaces/styleResponse.d.ts.map +1 -0
- package/dist/es/interfaces/styleResponse.js +2 -0
- package/dist/es/interfaces/styleResponse.js.map +1 -0
- package/dist/es/logger/logger.d.ts +14 -0
- package/dist/es/logger/logger.d.ts.map +1 -0
- package/dist/es/logger/logger.js +84 -0
- package/dist/es/logger/logger.js.map +1 -0
- package/dist/es/logger/rollbar.d.ts +4 -0
- package/dist/es/logger/rollbar.d.ts.map +1 -0
- package/dist/es/logger/rollbar.js +20 -0
- package/dist/es/logger/rollbar.js.map +1 -0
- package/dist/es/map/map.d.ts +598 -0
- package/dist/es/map/map.d.ts.map +1 -0
- package/dist/es/map/map.js +1430 -0
- package/dist/es/map/map.js.map +1 -0
- package/dist/es/repository/repository.d.ts +65 -0
- package/dist/es/repository/repository.d.ts.map +1 -0
- package/dist/es/repository/repository.js +570 -0
- package/dist/es/repository/repository.js.map +1 -0
- package/dist/es/repository/requester.d.ts +169 -0
- package/dist/es/repository/requester.d.ts.map +1 -0
- package/dist/es/repository/requester.js +586 -0
- package/dist/es/repository/requester.js.map +1 -0
- package/dist/es/sdk.d.ts +279 -0
- package/dist/es/sdk.d.ts.map +1 -0
- package/dist/es/sdk.js +346 -0
- package/dist/es/sdk.js.map +1 -0
- package/dist/es/utils/error.d.ts +8 -0
- package/dist/es/utils/error.d.ts.map +1 -0
- package/dist/es/utils/error.js +16 -0
- package/dist/es/utils/error.js.map +1 -0
- package/dist/es/utils/images.d.ts +8 -0
- package/dist/es/utils/images.d.ts.map +1 -0
- package/dist/es/utils/images.js +22 -0
- package/dist/es/utils/images.js.map +1 -0
- package/dist/es/utils/nav-functions.d.ts +85 -0
- package/dist/es/utils/nav-functions.d.ts.map +1 -0
- package/dist/es/utils/nav-functions.js +143 -0
- package/dist/es/utils/nav-functions.js.map +1 -0
- package/dist/es/utils/opening-hours-helper.d.ts +395 -0
- package/dist/es/utils/opening-hours-helper.d.ts.map +1 -0
- package/dist/es/utils/opening-hours-helper.js +906 -0
- package/dist/es/utils/opening-hours-helper.js.map +1 -0
- package/dist/es/utils/route-utils.d.ts +28 -0
- package/dist/es/utils/route-utils.d.ts.map +1 -0
- package/dist/es/utils/route-utils.js +54 -0
- package/dist/es/utils/route-utils.js.map +1 -0
- package/dist/es/utils/update-css.d.ts +12 -0
- package/dist/es/utils/update-css.d.ts.map +1 -0
- package/dist/es/utils/update-css.js +73 -0
- package/dist/es/utils/update-css.js.map +1 -0
- package/dist/es/utils/utils.d.ts +39 -0
- package/dist/es/utils/utils.d.ts.map +1 -0
- package/dist/es/utils/utils.js +97 -0
- package/dist/es/utils/utils.js.map +1 -0
- package/dist/umd/index.js +16874 -0
- package/dist/umd/index.js.map +1 -0
- package/dist/umd/styles.css +107 -0
- package/dist/umd/styles.css.map +1 -0
- package/dist/umd/styles.js +37 -0
- package/dist/umd/styles.js.map +1 -0
- package/package.json +198 -0
|
@@ -0,0 +1,1050 @@
|
|
|
1
|
+
import { MarkerAttribute } from "../domain/models/marker";
|
|
2
|
+
import { NavFunctions, compareLatLng } from "../utils/nav-functions";
|
|
3
|
+
import { createPositionsForStops, createStops } from "../utils/utils";
|
|
4
|
+
import { createRouteInstance } from "../domain/models/routeInstance";
|
|
5
|
+
/**
|
|
6
|
+
* Default padding values for auto-fit by place feature.
|
|
7
|
+
* Used when padding is not explicitly provided in the animation configuration.
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_AUTO_FIT_PADDING = {
|
|
10
|
+
top: 150,
|
|
11
|
+
right: 150,
|
|
12
|
+
bottom: 150,
|
|
13
|
+
left: 150,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Represents the controller for routes on the map.
|
|
17
|
+
* Supports multiple simultaneous routes with independent customizations,
|
|
18
|
+
* animations, and lifecycle management.
|
|
19
|
+
* @group Routes
|
|
20
|
+
*/
|
|
21
|
+
export class RouteController {
|
|
22
|
+
constructor(map) {
|
|
23
|
+
this.routes = new Map();
|
|
24
|
+
this.mapvxMap = map;
|
|
25
|
+
}
|
|
26
|
+
get map() {
|
|
27
|
+
return this.mapvxMap.map;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resolve a route instance by ID, or fall back to the last added route.
|
|
31
|
+
*/
|
|
32
|
+
resolveInstance(routeId) {
|
|
33
|
+
const id = routeId !== null && routeId !== void 0 ? routeId : this.lastAddedRouteId;
|
|
34
|
+
return id ? this.routes.get(id) : undefined;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Add MapLibre sources and layers for a single route instance.
|
|
38
|
+
*/
|
|
39
|
+
addSourcesAndLayersForRoute(instance) {
|
|
40
|
+
this.map.addSource(instance.aheadId, {
|
|
41
|
+
type: "geojson",
|
|
42
|
+
data: instance.aheadSourceData,
|
|
43
|
+
});
|
|
44
|
+
this.map.addLayer({
|
|
45
|
+
id: instance.aheadId,
|
|
46
|
+
type: "line",
|
|
47
|
+
source: instance.aheadId,
|
|
48
|
+
layout: {
|
|
49
|
+
"line-join": "round",
|
|
50
|
+
"line-cap": "round",
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
this.map.addSource(instance.behindId, {
|
|
54
|
+
type: "geojson",
|
|
55
|
+
data: instance.behindSourceData,
|
|
56
|
+
});
|
|
57
|
+
this.map.addLayer({
|
|
58
|
+
id: instance.behindId,
|
|
59
|
+
type: "line",
|
|
60
|
+
source: instance.behindId,
|
|
61
|
+
layout: {
|
|
62
|
+
"line-join": "round",
|
|
63
|
+
"line-cap": "round",
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
this.map.addSource(instance.currentId, {
|
|
67
|
+
type: "geojson",
|
|
68
|
+
data: instance.currentSourceData,
|
|
69
|
+
});
|
|
70
|
+
this.map.addLayer({
|
|
71
|
+
id: instance.currentId,
|
|
72
|
+
type: "line",
|
|
73
|
+
source: instance.currentId,
|
|
74
|
+
layout: {
|
|
75
|
+
"line-join": "round",
|
|
76
|
+
"line-cap": "round",
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Remove MapLibre sources and layers for a single route instance.
|
|
82
|
+
*/
|
|
83
|
+
removeSourcesAndLayersForRoute(instance) {
|
|
84
|
+
const ids = [instance.aheadId, instance.behindId, instance.currentId];
|
|
85
|
+
for (const id of ids) {
|
|
86
|
+
try {
|
|
87
|
+
this.map.removeLayer(id);
|
|
88
|
+
}
|
|
89
|
+
catch (_a) {
|
|
90
|
+
// Layer may not exist
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
this.map.removeSource(id);
|
|
94
|
+
}
|
|
95
|
+
catch (_b) {
|
|
96
|
+
// Source may not exist
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Re-add sources and layers for all active routes.
|
|
102
|
+
* Should be called when the map style is reloaded.
|
|
103
|
+
*/
|
|
104
|
+
addSourcesAndLayers() {
|
|
105
|
+
for (const instance of this.routes.values()) {
|
|
106
|
+
this.addSourcesAndLayersForRoute(instance);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Add a route to the map.
|
|
111
|
+
* @param route The route to add.
|
|
112
|
+
* @param drawConfig The draw configuration for the route.
|
|
113
|
+
*/
|
|
114
|
+
addRoute(route, drawConfig) {
|
|
115
|
+
const instance = createRouteInstance(route);
|
|
116
|
+
this.routes.set(instance.id, instance);
|
|
117
|
+
this.lastAddedRouteId = instance.id;
|
|
118
|
+
this.addSourcesAndLayersForRoute(instance);
|
|
119
|
+
this.setSourceData(instance, instance.aheadId, route.steps);
|
|
120
|
+
this.setLayerPaint(instance.aheadId, drawConfig);
|
|
121
|
+
this.updateLayerFilter(instance.aheadId);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Update the visual progress of a route based on an external user position.
|
|
125
|
+
* Splits the route into behind (already traveled) and ahead (remaining) sections
|
|
126
|
+
* at the point on the route closest to the given position.
|
|
127
|
+
*
|
|
128
|
+
* @param routeId The ID of the route to update.
|
|
129
|
+
* @param position The current user position (will be projected onto the route).
|
|
130
|
+
* @param behindDrawConfig The draw configuration for the behind (traveled) portion.
|
|
131
|
+
*/
|
|
132
|
+
updateRouteProgress(routeId, position, behindDrawConfig) {
|
|
133
|
+
const instance = this.routes.get(routeId);
|
|
134
|
+
if (!instance)
|
|
135
|
+
return;
|
|
136
|
+
const route = instance.route;
|
|
137
|
+
const steps = route.steps;
|
|
138
|
+
// Find the closest point on the route to the position
|
|
139
|
+
let bestDist = Infinity;
|
|
140
|
+
let bestStepIndex = 0;
|
|
141
|
+
let bestCoordIndex = 0;
|
|
142
|
+
let bestFraction = 0;
|
|
143
|
+
for (let s = 0; s < steps.length; s++) {
|
|
144
|
+
const coords = steps[s].coordinates;
|
|
145
|
+
for (let c = 0; c < coords.length - 1; c++) {
|
|
146
|
+
const a = coords[c];
|
|
147
|
+
const b = coords[c + 1];
|
|
148
|
+
const { fraction, dist } = this.projectPointToSegment(position, a, b);
|
|
149
|
+
if (dist < bestDist) {
|
|
150
|
+
bestDist = dist;
|
|
151
|
+
bestStepIndex = s;
|
|
152
|
+
bestCoordIndex = c;
|
|
153
|
+
bestFraction = fraction;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Build behind features: all complete steps before the best step,
|
|
158
|
+
// plus the partial segment of the current step up to the projected point
|
|
159
|
+
const behindFeatures = [];
|
|
160
|
+
for (let s = 0; s < bestStepIndex; s++) {
|
|
161
|
+
behindFeatures.push({
|
|
162
|
+
type: "Feature",
|
|
163
|
+
properties: { floor_key: this.getFloorKeyForStep(steps[s]) },
|
|
164
|
+
geometry: {
|
|
165
|
+
type: "LineString",
|
|
166
|
+
coordinates: steps[s].geoJsonCoordinates,
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
// Partial behind feature for the current step (up to projected point)
|
|
171
|
+
const currentStep = steps[bestStepIndex];
|
|
172
|
+
const currentCoords = currentStep.coordinates;
|
|
173
|
+
const partialBehindCoords = [];
|
|
174
|
+
for (let c = 0; c <= bestCoordIndex; c++) {
|
|
175
|
+
partialBehindCoords.push([currentCoords[c].lng, currentCoords[c].lat]);
|
|
176
|
+
}
|
|
177
|
+
// Add the projected point
|
|
178
|
+
const a = currentCoords[bestCoordIndex];
|
|
179
|
+
const b = currentCoords[Math.min(bestCoordIndex + 1, currentCoords.length - 1)];
|
|
180
|
+
const projLat = a.lat + bestFraction * (b.lat - a.lat);
|
|
181
|
+
const projLng = a.lng + bestFraction * (b.lng - a.lng);
|
|
182
|
+
partialBehindCoords.push([projLng, projLat]);
|
|
183
|
+
if (partialBehindCoords.length >= 2) {
|
|
184
|
+
behindFeatures.push({
|
|
185
|
+
type: "Feature",
|
|
186
|
+
properties: { floor_key: this.getFloorKeyForStep(currentStep) },
|
|
187
|
+
geometry: { type: "LineString", coordinates: partialBehindCoords },
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
// Build ahead features: partial remainder of current step + all remaining steps
|
|
191
|
+
const aheadFeatures = [];
|
|
192
|
+
const partialAheadCoords = [[projLng, projLat]];
|
|
193
|
+
for (let c = bestCoordIndex + 1; c < currentCoords.length; c++) {
|
|
194
|
+
partialAheadCoords.push([currentCoords[c].lng, currentCoords[c].lat]);
|
|
195
|
+
}
|
|
196
|
+
if (partialAheadCoords.length >= 2) {
|
|
197
|
+
aheadFeatures.push({
|
|
198
|
+
type: "Feature",
|
|
199
|
+
properties: { floor_key: this.getFloorKeyForStep(currentStep) },
|
|
200
|
+
geometry: { type: "LineString", coordinates: partialAheadCoords },
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
for (let s = bestStepIndex + 1; s < steps.length; s++) {
|
|
204
|
+
aheadFeatures.push({
|
|
205
|
+
type: "Feature",
|
|
206
|
+
properties: { floor_key: this.getFloorKeyForStep(steps[s]) },
|
|
207
|
+
geometry: {
|
|
208
|
+
type: "LineString",
|
|
209
|
+
coordinates: steps[s].geoJsonCoordinates,
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
// Update sources
|
|
214
|
+
instance.behindSourceData.features = behindFeatures;
|
|
215
|
+
const behindSource = this.map.getSource(instance.behindId);
|
|
216
|
+
behindSource === null || behindSource === void 0 ? void 0 : behindSource.setData(instance.behindSourceData);
|
|
217
|
+
instance.aheadSourceData.features = aheadFeatures;
|
|
218
|
+
const aheadSource = this.map.getSource(instance.aheadId);
|
|
219
|
+
aheadSource === null || aheadSource === void 0 ? void 0 : aheadSource.setData(instance.aheadSourceData);
|
|
220
|
+
// Ensure paint is set on the behind layer
|
|
221
|
+
this.setLayerPaint(instance.behindId, behindDrawConfig);
|
|
222
|
+
this.updateLayerFilter(instance.behindId);
|
|
223
|
+
this.updateLayerFilter(instance.aheadId);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Project a point onto a line segment and return the clamped fraction and squared distance.
|
|
227
|
+
*/
|
|
228
|
+
projectPointToSegment(p, a, b) {
|
|
229
|
+
const dx = b.lng - a.lng;
|
|
230
|
+
const dy = b.lat - a.lat;
|
|
231
|
+
const lenSq = dx * dx + dy * dy;
|
|
232
|
+
if (lenSq === 0) {
|
|
233
|
+
const ddx = p.lng - a.lng;
|
|
234
|
+
const ddy = p.lat - a.lat;
|
|
235
|
+
return { fraction: 0, dist: ddx * ddx + ddy * ddy };
|
|
236
|
+
}
|
|
237
|
+
let t = ((p.lng - a.lng) * dx + (p.lat - a.lat) * dy) / lenSq;
|
|
238
|
+
t = Math.max(0, Math.min(1, t));
|
|
239
|
+
const projLng = a.lng + t * dx;
|
|
240
|
+
const projLat = a.lat + t * dy;
|
|
241
|
+
const ddx = p.lng - projLng;
|
|
242
|
+
const ddy = p.lat - projLat;
|
|
243
|
+
return { fraction: t, dist: ddx * ddx + ddy * ddy };
|
|
244
|
+
}
|
|
245
|
+
setSourceData(instance, id, steps) {
|
|
246
|
+
const features = this.createFeaturesFrom(steps);
|
|
247
|
+
const source = this.map.getSource(id);
|
|
248
|
+
if (id === instance.aheadId) {
|
|
249
|
+
instance.aheadSourceData.features = features;
|
|
250
|
+
source === null || source === void 0 ? void 0 : source.setData(instance.aheadSourceData);
|
|
251
|
+
}
|
|
252
|
+
else if (id === instance.behindId) {
|
|
253
|
+
instance.behindSourceData.features = features;
|
|
254
|
+
source === null || source === void 0 ? void 0 : source.setData(instance.behindSourceData);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
setCurrentSourceData(instance, step) {
|
|
258
|
+
instance.currentSourceData.properties = {
|
|
259
|
+
floor_key: this.getFloorKeyForStep(step),
|
|
260
|
+
};
|
|
261
|
+
const coordinate = step === null || step === void 0 ? void 0 : step.coordinates[0];
|
|
262
|
+
if (coordinate != null) {
|
|
263
|
+
instance.currentSourceData.geometry.coordinates = [[coordinate.lng, coordinate.lat]];
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
instance.currentSourceData.geometry.coordinates = [];
|
|
267
|
+
}
|
|
268
|
+
const source = this.map.getSource(instance.currentId);
|
|
269
|
+
source === null || source === void 0 ? void 0 : source.setData(instance.currentSourceData);
|
|
270
|
+
}
|
|
271
|
+
setLayerPaint(layerId, drawConfig) {
|
|
272
|
+
const paintConfig = this.preparePaintForLayer(drawConfig);
|
|
273
|
+
for (const property in paintConfig) {
|
|
274
|
+
this.map.setPaintProperty(layerId, property, paintConfig[property]);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
preparePaintForLayer(drawConfig) {
|
|
278
|
+
if ("color" in drawConfig.routeStyle) {
|
|
279
|
+
// Check for propriety unique to SolidStyle
|
|
280
|
+
return {
|
|
281
|
+
"line-color": drawConfig.routeStyle.color,
|
|
282
|
+
"line-gradient": null,
|
|
283
|
+
"line-width": drawConfig.polylineWidth,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
// Is GradienteStyle
|
|
288
|
+
const { colors, positions } = drawConfig.routeStyle;
|
|
289
|
+
let positionsToUse = positions;
|
|
290
|
+
if (positionsToUse == null) {
|
|
291
|
+
positionsToUse = createPositionsForStops(colors.length);
|
|
292
|
+
}
|
|
293
|
+
if (positionsToUse.length !== colors.length) {
|
|
294
|
+
throw new Error("Error: position array has different length than colors array");
|
|
295
|
+
}
|
|
296
|
+
const stops = createStops(positionsToUse, colors);
|
|
297
|
+
const gradient = [
|
|
298
|
+
"interpolate",
|
|
299
|
+
["linear"],
|
|
300
|
+
["line-progress"],
|
|
301
|
+
...stops,
|
|
302
|
+
];
|
|
303
|
+
return {
|
|
304
|
+
"line-color": null,
|
|
305
|
+
"line-gradient": gradient,
|
|
306
|
+
"line-width": drawConfig.polylineWidth,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Update the filter of the layer referenced with a ID.
|
|
312
|
+
*
|
|
313
|
+
* @see {@link https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/#setfilter}
|
|
314
|
+
* @param layerId The ID for the layer.
|
|
315
|
+
*/
|
|
316
|
+
updateLayerFilter(layerId, floorId) {
|
|
317
|
+
const newFloorId = floorId !== null && floorId !== void 0 ? floorId : this.mapvxMap.getCurrentFloor();
|
|
318
|
+
if (newFloorId === undefined)
|
|
319
|
+
return;
|
|
320
|
+
if (this.map.getStyle().layers.some((layer) => layer.id === layerId)) {
|
|
321
|
+
this.map.setFilter(layerId, ["==", ["get", "floor_key"], newFloorId]);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Determines the correct floor_key for a route step.
|
|
326
|
+
* Outdoor steps (without startInsideFloor) should use the outdoor floor key,
|
|
327
|
+
* not the current floor which might be indoor.
|
|
328
|
+
* Elevator steps are always drawn on startInsideFloor; floor is updated to endInsideFloor
|
|
329
|
+
* only when the step completes (see prepareForNextStep / animateStep).
|
|
330
|
+
* @param step The route step to determine the floor_key for
|
|
331
|
+
* @returns The floor_key string to use for the step
|
|
332
|
+
*/
|
|
333
|
+
getFloorKeyForStep(step) {
|
|
334
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
335
|
+
if (!step) {
|
|
336
|
+
return this.mapvxMap.getCurrentFloor();
|
|
337
|
+
}
|
|
338
|
+
// If step has startInsideFloor, use it (unless it's a non-elevator floor change step)
|
|
339
|
+
if (((_b = (_a = step.startInsideFloor) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0) {
|
|
340
|
+
// If step changes floors (different start and end) and is not an elevator step,
|
|
341
|
+
// use endInsideFloor so the step is drawn on the destination floor.
|
|
342
|
+
// Elevator steps are drawn on startInsideFloor; floor updates on step completion.
|
|
343
|
+
if (((_d = (_c = step.endInsideFloor) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0 &&
|
|
344
|
+
step.startInsideFloor !== step.endInsideFloor &&
|
|
345
|
+
!step.elevatorStep) {
|
|
346
|
+
return step.endInsideFloor;
|
|
347
|
+
}
|
|
348
|
+
return step.startInsideFloor;
|
|
349
|
+
}
|
|
350
|
+
// If step has endInsideFloor but no startInsideFloor (entering building), use endInsideFloor
|
|
351
|
+
if (((_f = (_e = step.endInsideFloor) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0) > 0) {
|
|
352
|
+
return step.endInsideFloor;
|
|
353
|
+
}
|
|
354
|
+
// If step is outdoor (no startInsideFloor and no endInsideFloor), use outdoor floor key
|
|
355
|
+
const innerFloors = this.mapvxMap.getInnerFloors();
|
|
356
|
+
const outdoorFloor = innerFloors.find((floor) => floor.reachableFromGPS === true);
|
|
357
|
+
return (_g = outdoorFloor === null || outdoorFloor === void 0 ? void 0 : outdoorFloor.key) !== null && _g !== void 0 ? _g : "";
|
|
358
|
+
}
|
|
359
|
+
createFeaturesFrom(steps) {
|
|
360
|
+
const features = steps.map((step) => {
|
|
361
|
+
return {
|
|
362
|
+
type: "Feature",
|
|
363
|
+
properties: { floor_key: this.getFloorKeyForStep(step) },
|
|
364
|
+
geometry: {
|
|
365
|
+
type: "LineString",
|
|
366
|
+
coordinates: step.geoJsonCoordinates,
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
});
|
|
370
|
+
return features;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Update the layers for all active routes.
|
|
374
|
+
* @param floorId The floor ID to update the layers for.
|
|
375
|
+
*/
|
|
376
|
+
updateRouteLayers(floorId) {
|
|
377
|
+
for (const instance of this.routes.values()) {
|
|
378
|
+
this.updateLayerFilter(instance.aheadId, floorId);
|
|
379
|
+
this.updateLayerFilter(instance.behindId, floorId);
|
|
380
|
+
this.updateLayerFilter(instance.currentId, floorId);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Update the visibility of route markers for all active routes.
|
|
385
|
+
* @param floorId The floor ID to update the visibility for.
|
|
386
|
+
*/
|
|
387
|
+
updateRouteMarkerVisibility(floorId) {
|
|
388
|
+
var _a, _b, _c;
|
|
389
|
+
for (const instance of this.routes.values()) {
|
|
390
|
+
((_a = instance.routeMarker) === null || _a === void 0 ? void 0 : _a.floorId) === floorId
|
|
391
|
+
? (_b = instance.routeMarker) === null || _b === void 0 ? void 0 : _b.show(this.map)
|
|
392
|
+
: (_c = instance.routeMarker) === null || _c === void 0 ? void 0 : _c.hide();
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
updatePlaceFloorForRouting(instance, placeId, floorKey) {
|
|
396
|
+
var _a;
|
|
397
|
+
if (placeId && floorKey) {
|
|
398
|
+
this.mapvxMap.updatePlaceAndFloorForRouting(placeId, floorKey);
|
|
399
|
+
this.updateRouteLayers(floorKey);
|
|
400
|
+
(_a = instance.routeMarker) === null || _a === void 0 ? void 0 : _a.setFloor(floorKey);
|
|
401
|
+
this.updateRouteMarkerVisibility(floorKey);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Start the animation of a route.
|
|
406
|
+
* @param route The route to animate.
|
|
407
|
+
* @param drawConfig The draw configuration for the route.
|
|
408
|
+
* @param animationConfig The animation configuration for the route.
|
|
409
|
+
*/
|
|
410
|
+
startAnimating(route, drawConfig, animationConfig) {
|
|
411
|
+
var _a, _b, _c;
|
|
412
|
+
const instance = createRouteInstance(route);
|
|
413
|
+
this.routes.set(instance.id, instance);
|
|
414
|
+
this.lastAddedRouteId = instance.id;
|
|
415
|
+
instance.animationStatus = "STARTED";
|
|
416
|
+
instance.route = route;
|
|
417
|
+
const firstStep = route.steps[0];
|
|
418
|
+
this.addSourcesAndLayersForRoute(instance);
|
|
419
|
+
this.updatePlaceFloorForRouting(instance, firstStep.startInsidePlace, firstStep.startInsideFloor);
|
|
420
|
+
this.setSourceData(instance, instance.aheadId, route.steps);
|
|
421
|
+
this.setSourceData(instance, instance.behindId, []);
|
|
422
|
+
instance.currentSourceData.properties = {
|
|
423
|
+
floor_key: this.getFloorKeyForStep(firstStep),
|
|
424
|
+
};
|
|
425
|
+
instance.currentSourceData.geometry.coordinates = [
|
|
426
|
+
[firstStep.coordinates[0].lng, firstStep.coordinates[0].lat],
|
|
427
|
+
];
|
|
428
|
+
this.setLayerPaint(instance.aheadId, drawConfig.aheadConfig);
|
|
429
|
+
this.setLayerPaint(instance.behindId, drawConfig.behindConfig);
|
|
430
|
+
this.setLayerPaint(instance.currentId, drawConfig.behindConfig);
|
|
431
|
+
instance.animationConfig = animationConfig;
|
|
432
|
+
instance.routeMarker = new MarkerAttribute({
|
|
433
|
+
coordinate: firstStep.startLocation,
|
|
434
|
+
floorId: firstStep.startInsideFloor,
|
|
435
|
+
icon: drawConfig.routeIcon,
|
|
436
|
+
rotationAlignment: "map",
|
|
437
|
+
});
|
|
438
|
+
instance.routeMarker.addToMap(this.map);
|
|
439
|
+
// Auto-fit by place if enabled
|
|
440
|
+
if (((_a = animationConfig.autoFitByPlace) === null || _a === void 0 ? void 0 : _a.enabled) && route.steps.length > 0) {
|
|
441
|
+
if (firstStep.startInsidePlace) {
|
|
442
|
+
instance.currentPlaceId = firstStep.startInsidePlace;
|
|
443
|
+
const fitOptions = {
|
|
444
|
+
padding: (_b = animationConfig.autoFitByPlace.padding) !== null && _b !== void 0 ? _b : DEFAULT_AUTO_FIT_PADDING,
|
|
445
|
+
};
|
|
446
|
+
this.mapvxMap.fitRouteByPlace(route, firstStep.startInsidePlace, fitOptions);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
(_c = animationConfig.callBack) === null || _c === void 0 ? void 0 : _c.call(animationConfig, { isFinished: false, step: firstStep });
|
|
450
|
+
instance.conditions = {
|
|
451
|
+
index: 0,
|
|
452
|
+
coordinatesIndex: 0,
|
|
453
|
+
iconRotation: 0,
|
|
454
|
+
rotatingIcon: true,
|
|
455
|
+
startTime: undefined,
|
|
456
|
+
progress: 0,
|
|
457
|
+
resetTime: false,
|
|
458
|
+
waitStartTime: undefined,
|
|
459
|
+
animationId: requestAnimationFrame((time) => this.animateStep(time, instance)),
|
|
460
|
+
onFinish: (time) => this.prepareForNextStep(time, instance),
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
clearRouteInstance(instance) {
|
|
464
|
+
var _a;
|
|
465
|
+
(_a = instance.routeMarker) === null || _a === void 0 ? void 0 : _a.remove();
|
|
466
|
+
instance.routeMarker = undefined;
|
|
467
|
+
this.setSourceData(instance, instance.aheadId, []);
|
|
468
|
+
this.setSourceData(instance, instance.behindId, []);
|
|
469
|
+
instance.currentSourceData.geometry.coordinates = [];
|
|
470
|
+
const source = this.map.getSource(instance.currentId);
|
|
471
|
+
source === null || source === void 0 ? void 0 : source.setData(instance.currentSourceData);
|
|
472
|
+
if ((instance.animationStatus === "STARTED" || instance.stepAnimationStatus === "ANIMATING") &&
|
|
473
|
+
instance.conditions != null) {
|
|
474
|
+
cancelAnimationFrame(instance.conditions.animationId);
|
|
475
|
+
}
|
|
476
|
+
instance.animationStatus = "NO_ROUTE";
|
|
477
|
+
instance.stepAnimationStatus = "NO_ROUTE";
|
|
478
|
+
instance.conditions = undefined;
|
|
479
|
+
instance.animationConfig = undefined;
|
|
480
|
+
instance.currentPlaceId = undefined;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Remove a route from the map.
|
|
484
|
+
* @param routeId The ID of the route to remove. If not provided, removes the last added route.
|
|
485
|
+
*/
|
|
486
|
+
removeRoute(routeId) {
|
|
487
|
+
const instance = this.resolveInstance(routeId);
|
|
488
|
+
if (!instance)
|
|
489
|
+
return;
|
|
490
|
+
this.clearRouteInstance(instance);
|
|
491
|
+
this.removeSourcesAndLayersForRoute(instance);
|
|
492
|
+
this.routes.delete(instance.id);
|
|
493
|
+
if (this.lastAddedRouteId === instance.id) {
|
|
494
|
+
const remaining = [...this.routes.keys()];
|
|
495
|
+
this.lastAddedRouteId = remaining.length > 0 ? remaining[remaining.length - 1] : undefined;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Remove all routes from the map.
|
|
500
|
+
*/
|
|
501
|
+
removeAllRoutes() {
|
|
502
|
+
for (const instance of this.routes.values()) {
|
|
503
|
+
this.clearRouteInstance(instance);
|
|
504
|
+
this.removeSourcesAndLayersForRoute(instance);
|
|
505
|
+
}
|
|
506
|
+
this.routes.clear();
|
|
507
|
+
this.lastAddedRouteId = undefined;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Get the IDs of all active routes on the map.
|
|
511
|
+
* @returns Array of route IDs.
|
|
512
|
+
*/
|
|
513
|
+
getRouteIds() {
|
|
514
|
+
return [...this.routes.keys()];
|
|
515
|
+
}
|
|
516
|
+
internalPause(instance) {
|
|
517
|
+
if (instance.animationStatus != "STARTED")
|
|
518
|
+
return;
|
|
519
|
+
if (instance.conditions == null)
|
|
520
|
+
return;
|
|
521
|
+
cancelAnimationFrame(instance.conditions.animationId);
|
|
522
|
+
instance.animationStatus = "PAUSED";
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Pause the animation of a route.
|
|
526
|
+
* @param routeId The ID of the route. If not provided, pauses the last added route.
|
|
527
|
+
*/
|
|
528
|
+
pauseAnimation(routeId) {
|
|
529
|
+
const instance = this.resolveInstance(routeId);
|
|
530
|
+
if (!instance)
|
|
531
|
+
return;
|
|
532
|
+
this.internalPause(instance);
|
|
533
|
+
}
|
|
534
|
+
internalResume(instance) {
|
|
535
|
+
if (instance.animationStatus != "PAUSED")
|
|
536
|
+
return;
|
|
537
|
+
if (instance.conditions == null)
|
|
538
|
+
return;
|
|
539
|
+
instance.conditions.resetTime = true;
|
|
540
|
+
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
541
|
+
instance.animationStatus = "STARTED";
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Resume the animation of a route.
|
|
545
|
+
* @param routeId The ID of the route. If not provided, resumes the last added route.
|
|
546
|
+
*/
|
|
547
|
+
resumeAnimation(routeId) {
|
|
548
|
+
const instance = this.resolveInstance(routeId);
|
|
549
|
+
if (!instance)
|
|
550
|
+
return;
|
|
551
|
+
this.internalResume(instance);
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Restart the animation of a route.
|
|
555
|
+
* @param routeId The ID of the route. If not provided, restarts the last added route.
|
|
556
|
+
*/
|
|
557
|
+
restartAnimation(routeId) {
|
|
558
|
+
var _a, _b, _c, _d, _e;
|
|
559
|
+
const instance = this.resolveInstance(routeId);
|
|
560
|
+
if (!instance) {
|
|
561
|
+
throw new Error("Does not exist animated route to restart");
|
|
562
|
+
}
|
|
563
|
+
if (instance.animationStatus === "NO_ROUTE") {
|
|
564
|
+
throw new Error("Does not exist animated route to restart");
|
|
565
|
+
}
|
|
566
|
+
if (instance.conditions == null ||
|
|
567
|
+
instance.animationConfig == null ||
|
|
568
|
+
instance.route == null ||
|
|
569
|
+
instance.routeMarker == null) {
|
|
570
|
+
throw new Error("Error: conditions and animationConfig should not be null at this point");
|
|
571
|
+
}
|
|
572
|
+
if (instance.animationStatus === "STARTED") {
|
|
573
|
+
cancelAnimationFrame(instance.conditions.animationId);
|
|
574
|
+
}
|
|
575
|
+
instance.animationStatus = "STARTED";
|
|
576
|
+
const firstStep = instance.route.steps[0];
|
|
577
|
+
this.updatePlaceFloorForRouting(instance, firstStep.startInsidePlace, firstStep.startInsideFloor);
|
|
578
|
+
this.setSourceData(instance, instance.aheadId, instance.route.steps);
|
|
579
|
+
this.setSourceData(instance, instance.behindId, []);
|
|
580
|
+
instance.currentSourceData.properties = {
|
|
581
|
+
floor_key: this.getFloorKeyForStep(firstStep),
|
|
582
|
+
};
|
|
583
|
+
instance.currentSourceData.geometry.coordinates = [
|
|
584
|
+
[firstStep.coordinates[0].lng, firstStep.coordinates[0].lat],
|
|
585
|
+
];
|
|
586
|
+
const source = this.map.getSource(instance.currentId);
|
|
587
|
+
source === null || source === void 0 ? void 0 : source.setData(instance.currentSourceData);
|
|
588
|
+
(_a = this.setMarkerRotation(instance, 0)) === null || _a === void 0 ? void 0 : _a.setLngLat(firstStep.startLocation).addTo(this.map);
|
|
589
|
+
// Auto-fit by place if enabled
|
|
590
|
+
if (((_b = instance.animationConfig.autoFitByPlace) === null || _b === void 0 ? void 0 : _b.enabled) && instance.route.steps.length > 0) {
|
|
591
|
+
if (firstStep.startInsidePlace) {
|
|
592
|
+
instance.currentPlaceId = firstStep.startInsidePlace;
|
|
593
|
+
const fitOptions = {
|
|
594
|
+
padding: (_c = instance.animationConfig.autoFitByPlace.padding) !== null && _c !== void 0 ? _c : DEFAULT_AUTO_FIT_PADDING,
|
|
595
|
+
};
|
|
596
|
+
this.mapvxMap.fitRouteByPlace(instance.route, firstStep.startInsidePlace, fitOptions);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
(_e = (_d = instance.animationConfig).callBack) === null || _e === void 0 ? void 0 : _e.call(_d, { isFinished: false, step: firstStep });
|
|
600
|
+
instance.conditions = {
|
|
601
|
+
index: 0,
|
|
602
|
+
coordinatesIndex: 0,
|
|
603
|
+
iconRotation: 0,
|
|
604
|
+
rotatingIcon: true,
|
|
605
|
+
startTime: undefined,
|
|
606
|
+
progress: 0,
|
|
607
|
+
resetTime: false,
|
|
608
|
+
waitStartTime: undefined,
|
|
609
|
+
animationId: requestAnimationFrame((time) => this.animateStep(time, instance)),
|
|
610
|
+
onFinish: (time) => this.prepareForNextStep(time, instance),
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Stop the animation of a route.
|
|
615
|
+
* @param routeId The ID of the route. If not provided, stops the last added route.
|
|
616
|
+
*/
|
|
617
|
+
stopAnimation(routeId) {
|
|
618
|
+
const instance = this.resolveInstance(routeId);
|
|
619
|
+
if (!instance)
|
|
620
|
+
return;
|
|
621
|
+
if (instance.animationStatus == "FINISHED") {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
// todo hacer cosas para detener animación
|
|
625
|
+
instance.animationStatus = "FINISHED";
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Add a step animation to a route.
|
|
629
|
+
* @param route The route to animate.
|
|
630
|
+
* @param drawConfig The draw configuration for the route.
|
|
631
|
+
* @param animationConfig The animation configuration for the route.
|
|
632
|
+
*/
|
|
633
|
+
addStepAnimation(route, drawConfig, animationConfig) {
|
|
634
|
+
var _a, _b, _c;
|
|
635
|
+
const instance = createRouteInstance(route);
|
|
636
|
+
this.routes.set(instance.id, instance);
|
|
637
|
+
this.lastAddedRouteId = instance.id;
|
|
638
|
+
instance.stepAnimationStatus = "WAITING";
|
|
639
|
+
instance.route = route;
|
|
640
|
+
const firstStep = route.steps[0];
|
|
641
|
+
this.addSourcesAndLayersForRoute(instance);
|
|
642
|
+
this.updatePlaceFloorForRouting(instance, firstStep.startInsidePlace, firstStep.startInsideFloor);
|
|
643
|
+
this.setSourceData(instance, instance.aheadId, route.steps);
|
|
644
|
+
this.setSourceData(instance, instance.behindId, []);
|
|
645
|
+
this.setCurrentSourceData(instance, firstStep);
|
|
646
|
+
this.setLayerPaint(instance.aheadId, drawConfig.aheadConfig);
|
|
647
|
+
this.setLayerPaint(instance.behindId, drawConfig.behindConfig);
|
|
648
|
+
this.setLayerPaint(instance.currentId, drawConfig.behindConfig);
|
|
649
|
+
instance.animationConfig = animationConfig;
|
|
650
|
+
instance.routeMarker = new MarkerAttribute({
|
|
651
|
+
coordinate: firstStep.startLocation,
|
|
652
|
+
floorId: firstStep.startInsideFloor,
|
|
653
|
+
icon: drawConfig.routeIcon,
|
|
654
|
+
rotationAlignment: "map",
|
|
655
|
+
});
|
|
656
|
+
instance.routeMarker.addToMap(this.map);
|
|
657
|
+
this.cameraFollow(instance, firstStep.startLocation);
|
|
658
|
+
// Auto-fit by place if enabled
|
|
659
|
+
if (((_a = animationConfig.autoFitByPlace) === null || _a === void 0 ? void 0 : _a.enabled) && route.steps.length > 0) {
|
|
660
|
+
if (firstStep.startInsidePlace) {
|
|
661
|
+
instance.currentPlaceId = firstStep.startInsidePlace;
|
|
662
|
+
const fitOptions = {
|
|
663
|
+
padding: (_b = animationConfig.autoFitByPlace.padding) !== null && _b !== void 0 ? _b : DEFAULT_AUTO_FIT_PADDING,
|
|
664
|
+
};
|
|
665
|
+
this.mapvxMap.fitRouteByPlace(route, firstStep.startInsidePlace, fitOptions);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
(_c = animationConfig.callBack) === null || _c === void 0 ? void 0 : _c.call(animationConfig, { isFinished: false, step: firstStep });
|
|
669
|
+
instance.conditions = {
|
|
670
|
+
index: 0,
|
|
671
|
+
coordinatesIndex: 0,
|
|
672
|
+
iconRotation: 0,
|
|
673
|
+
rotatingIcon: true,
|
|
674
|
+
startTime: undefined,
|
|
675
|
+
progress: 0,
|
|
676
|
+
resetTime: false,
|
|
677
|
+
waitStartTime: undefined,
|
|
678
|
+
animationId: 0,
|
|
679
|
+
isStepByStep: true,
|
|
680
|
+
onFinish: () => {
|
|
681
|
+
var _a, _b, _c, _d;
|
|
682
|
+
if (instance.conditions == null ||
|
|
683
|
+
instance.animationConfig == null ||
|
|
684
|
+
instance.route == null) {
|
|
685
|
+
throw new Error("Error: conditions, animationConfig or route should not be null at this point");
|
|
686
|
+
}
|
|
687
|
+
let { index } = instance.conditions;
|
|
688
|
+
index++;
|
|
689
|
+
const behindSteps = instance.route.steps.slice(0, index);
|
|
690
|
+
const aheadSteps = instance.route.steps.slice(index);
|
|
691
|
+
const step = instance.route.steps[index];
|
|
692
|
+
this.setSourceData(instance, instance.behindId, behindSteps);
|
|
693
|
+
this.setSourceData(instance, instance.aheadId, aheadSteps);
|
|
694
|
+
this.setCurrentSourceData(instance, step);
|
|
695
|
+
instance.conditions.index = index;
|
|
696
|
+
if (index < route.steps.length) {
|
|
697
|
+
const nextStep = route.steps[index];
|
|
698
|
+
// Auto-fit by place if enabled and place changed
|
|
699
|
+
if (((_a = animationConfig.autoFitByPlace) === null || _a === void 0 ? void 0 : _a.enabled) && nextStep && instance.route != null) {
|
|
700
|
+
const stepPlaceId = nextStep.startInsidePlace || nextStep.endInsidePlace;
|
|
701
|
+
if (stepPlaceId && stepPlaceId !== instance.currentPlaceId) {
|
|
702
|
+
instance.currentPlaceId = stepPlaceId;
|
|
703
|
+
const fitOptions = {
|
|
704
|
+
padding: (_b = animationConfig.autoFitByPlace.padding) !== null && _b !== void 0 ? _b : DEFAULT_AUTO_FIT_PADDING,
|
|
705
|
+
};
|
|
706
|
+
this.mapvxMap.fitRouteByPlace(instance.route, stepPlaceId, fitOptions);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
(_c = animationConfig.callBack) === null || _c === void 0 ? void 0 : _c.call(animationConfig, { isFinished: false, step: nextStep });
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
(_d = animationConfig.callBack) === null || _d === void 0 ? void 0 : _d.call(animationConfig, { isFinished: true, step: null });
|
|
713
|
+
}
|
|
714
|
+
instance.stepAnimationStatus = "WAITING";
|
|
715
|
+
},
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Animate the next step of a route.
|
|
720
|
+
* @param routeId The ID of the route. If not provided, uses the last added route.
|
|
721
|
+
*/
|
|
722
|
+
nextStepAnimation(routeId) {
|
|
723
|
+
const instance = this.resolveInstance(routeId);
|
|
724
|
+
if (!instance) {
|
|
725
|
+
throw new Error("Error: Does not exist step animation");
|
|
726
|
+
}
|
|
727
|
+
if (instance.stepAnimationStatus === "NO_ROUTE") {
|
|
728
|
+
throw new Error("Error: Does not exist step animation");
|
|
729
|
+
}
|
|
730
|
+
if (instance.conditions == null || instance.animationConfig == null || instance.route == null) {
|
|
731
|
+
throw new Error("Error: conditions, animationConfig or route should not be null at this point");
|
|
732
|
+
}
|
|
733
|
+
if (instance.stepAnimationStatus === "ANIMATING") {
|
|
734
|
+
cancelAnimationFrame(instance.conditions.animationId);
|
|
735
|
+
}
|
|
736
|
+
instance.stepAnimationStatus = "ANIMATING";
|
|
737
|
+
const { index } = instance.conditions;
|
|
738
|
+
if (index < instance.route.steps.length) {
|
|
739
|
+
instance.conditions.coordinatesIndex = 0;
|
|
740
|
+
instance.conditions.startTime = undefined;
|
|
741
|
+
instance.conditions.progress = 0;
|
|
742
|
+
instance.conditions.rotatingIcon = true;
|
|
743
|
+
instance.conditions.waitStartTime = undefined;
|
|
744
|
+
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
throw new Error("Error: Does not exist next step to animate");
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Go to the previous step of a route.
|
|
752
|
+
* @param routeId The ID of the route. If not provided, uses the last added route.
|
|
753
|
+
*/
|
|
754
|
+
previousStepAnimation(routeId) {
|
|
755
|
+
var _a, _b, _c, _d;
|
|
756
|
+
const instance = this.resolveInstance(routeId);
|
|
757
|
+
if (!instance) {
|
|
758
|
+
throw new Error("Error: Does not exist step animation");
|
|
759
|
+
}
|
|
760
|
+
if (instance.stepAnimationStatus === "NO_ROUTE") {
|
|
761
|
+
throw new Error("Error: Does not exist step animation");
|
|
762
|
+
}
|
|
763
|
+
if (instance.conditions == null || instance.animationConfig == null || instance.route == null) {
|
|
764
|
+
throw new Error("Error: conditions, animationConfig or route should not be null at this point");
|
|
765
|
+
}
|
|
766
|
+
if (instance.stepAnimationStatus === "ANIMATING") {
|
|
767
|
+
cancelAnimationFrame(instance.conditions.animationId);
|
|
768
|
+
}
|
|
769
|
+
instance.stepAnimationStatus = "WAITING";
|
|
770
|
+
let { index } = instance.conditions;
|
|
771
|
+
if (index > 0) {
|
|
772
|
+
index--;
|
|
773
|
+
const behindSteps = instance.route.steps.slice(0, index);
|
|
774
|
+
const aheadSteps = instance.route.steps.slice(index);
|
|
775
|
+
const step = instance.route.steps[index];
|
|
776
|
+
this.setSourceData(instance, instance.behindId, behindSteps);
|
|
777
|
+
this.setSourceData(instance, instance.aheadId, aheadSteps);
|
|
778
|
+
this.setCurrentSourceData(instance, step);
|
|
779
|
+
if (step.startInsideFloor != step.endInsideFloor && step.startInsideFloor) {
|
|
780
|
+
this.updatePlaceFloorForRouting(instance, step.startInsidePlace, step.startInsideFloor);
|
|
781
|
+
}
|
|
782
|
+
instance.conditions.index = index;
|
|
783
|
+
instance.conditions.coordinatesIndex = 0;
|
|
784
|
+
instance.conditions.startTime = undefined;
|
|
785
|
+
instance.conditions.progress = 0;
|
|
786
|
+
instance.conditions.rotatingIcon = true;
|
|
787
|
+
instance.conditions.waitStartTime = undefined;
|
|
788
|
+
this.setMarkerLngLat(instance, step.startLocation);
|
|
789
|
+
const previous = behindSteps.at(-1);
|
|
790
|
+
if (previous != null) {
|
|
791
|
+
const coordinates = previous.coordinates.slice(-2);
|
|
792
|
+
const angle = NavFunctions.bearingInDegBetween(coordinates[0], coordinates[1]);
|
|
793
|
+
this.setMarkerRotation(instance, angle);
|
|
794
|
+
}
|
|
795
|
+
else {
|
|
796
|
+
this.setMarkerRotation(instance, 0);
|
|
797
|
+
}
|
|
798
|
+
// Auto-fit by place if enabled and place changed
|
|
799
|
+
if (((_a = instance.animationConfig.autoFitByPlace) === null || _a === void 0 ? void 0 : _a.enabled) && step && instance.route != null) {
|
|
800
|
+
const stepPlaceId = step.startInsidePlace || step.endInsidePlace;
|
|
801
|
+
if (stepPlaceId && stepPlaceId !== instance.currentPlaceId) {
|
|
802
|
+
instance.currentPlaceId = stepPlaceId;
|
|
803
|
+
const fitOptions = {
|
|
804
|
+
padding: (_b = instance.animationConfig.autoFitByPlace.padding) !== null && _b !== void 0 ? _b : DEFAULT_AUTO_FIT_PADDING,
|
|
805
|
+
};
|
|
806
|
+
this.mapvxMap.fitRouteByPlace(instance.route, stepPlaceId, fitOptions);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
(_d = (_c = instance.animationConfig).callBack) === null || _d === void 0 ? void 0 : _d.call(_c, {
|
|
810
|
+
isFinished: false,
|
|
811
|
+
step,
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
else {
|
|
815
|
+
throw new Error("previous step doesn't exists to animate");
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Center on the current step of a route.
|
|
820
|
+
* @param routeId The ID of the route. If not provided, uses the last added route.
|
|
821
|
+
*/
|
|
822
|
+
centerOnCurrentStep(routeId) {
|
|
823
|
+
var _a;
|
|
824
|
+
const instance = this.resolveInstance(routeId);
|
|
825
|
+
if (!instance) {
|
|
826
|
+
throw new Error("Error: Does not exist step animation");
|
|
827
|
+
}
|
|
828
|
+
if (instance.stepAnimationStatus === "NO_ROUTE") {
|
|
829
|
+
throw new Error("Error: Does not exist step animation");
|
|
830
|
+
}
|
|
831
|
+
if (instance.conditions == null || instance.animationConfig == null || instance.route == null) {
|
|
832
|
+
throw new Error("Error: conditions, animationConfig or route should not be null at this point");
|
|
833
|
+
}
|
|
834
|
+
const currentMarkerPosition = (_a = instance.routeMarker) === null || _a === void 0 ? void 0 : _a.getLngLat();
|
|
835
|
+
if (currentMarkerPosition) {
|
|
836
|
+
this.map.panTo(currentMarkerPosition);
|
|
837
|
+
}
|
|
838
|
+
else {
|
|
839
|
+
throw new Error("Error: marker has no position set");
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
prepareForNextStep(timestamp, instance) {
|
|
843
|
+
var _a, _b, _c, _d, _e, _f;
|
|
844
|
+
if (instance.conditions == null || instance.animationConfig == null || instance.route == null) {
|
|
845
|
+
throw new Error("Error: conditions, animationConfig or route should not be null at this point");
|
|
846
|
+
}
|
|
847
|
+
const { index } = instance.conditions;
|
|
848
|
+
const behindSteps = instance.route.steps.slice(0, index + 1);
|
|
849
|
+
const aheadSteps = instance.route.steps.slice(index + 1);
|
|
850
|
+
this.setSourceData(instance, instance.behindId, behindSteps);
|
|
851
|
+
this.setSourceData(instance, instance.aheadId, aheadSteps);
|
|
852
|
+
instance.currentSourceData.geometry.coordinates = [];
|
|
853
|
+
if (index + 1 < instance.route.steps.length) {
|
|
854
|
+
const step = instance.route.steps[index + 1];
|
|
855
|
+
instance.currentSourceData.geometry.coordinates.push([
|
|
856
|
+
step.startLocation.lng,
|
|
857
|
+
step.startLocation.lat,
|
|
858
|
+
]);
|
|
859
|
+
instance.currentSourceData.properties = {
|
|
860
|
+
floor_key: this.getFloorKeyForStep(step),
|
|
861
|
+
};
|
|
862
|
+
instance.conditions.startTime = timestamp;
|
|
863
|
+
instance.conditions.index++;
|
|
864
|
+
instance.conditions.coordinatesIndex = 0;
|
|
865
|
+
instance.conditions.progress = 0;
|
|
866
|
+
instance.conditions.rotatingIcon = true;
|
|
867
|
+
if (!compareLatLng(instance.route.steps[index].endLocation, step.startLocation))
|
|
868
|
+
instance.conditions.nextFloorFirstStepIndex = index + 2;
|
|
869
|
+
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
870
|
+
// Auto-fit by place if enabled and place changed
|
|
871
|
+
if (((_a = instance.animationConfig.autoFitByPlace) === null || _a === void 0 ? void 0 : _a.enabled) && step && instance.route != null) {
|
|
872
|
+
const stepPlaceId = step.startInsidePlace || step.endInsidePlace;
|
|
873
|
+
if (stepPlaceId && stepPlaceId !== instance.currentPlaceId) {
|
|
874
|
+
instance.currentPlaceId = stepPlaceId;
|
|
875
|
+
const fitOptions = {
|
|
876
|
+
padding: (_b = instance.animationConfig.autoFitByPlace.padding) !== null && _b !== void 0 ? _b : DEFAULT_AUTO_FIT_PADDING,
|
|
877
|
+
};
|
|
878
|
+
this.mapvxMap.fitRouteByPlace(instance.route, stepPlaceId, fitOptions);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
(_d = (_c = instance.animationConfig).callBack) === null || _d === void 0 ? void 0 : _d.call(_c, {
|
|
882
|
+
isFinished: false,
|
|
883
|
+
step: instance.route.steps[index + 1],
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
else {
|
|
887
|
+
// finishes animation
|
|
888
|
+
(_f = (_e = instance.animationConfig).callBack) === null || _f === void 0 ? void 0 : _f.call(_e, { isFinished: true, step: null });
|
|
889
|
+
instance.animationStatus = "FINISHED";
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
animateStep(timestamp, instance) {
|
|
893
|
+
var _a, _b;
|
|
894
|
+
if (instance.conditions == null || instance.animationConfig == null || instance.route == null) {
|
|
895
|
+
throw new Error("Error: conditions and animationConfig should not be null at this point");
|
|
896
|
+
}
|
|
897
|
+
let { startTime, resetTime, progress } = instance.conditions;
|
|
898
|
+
const { coordinatesIndex, iconRotation, index, onFinish, rotatingIcon, waitStartTime } = instance.conditions;
|
|
899
|
+
const { stepTime, minimumSpeed, iconRotationTime, changeFloorTime } = instance.animationConfig;
|
|
900
|
+
if (startTime == null) {
|
|
901
|
+
instance.conditions.startTime = timestamp;
|
|
902
|
+
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
if (resetTime) {
|
|
906
|
+
startTime = timestamp - progress;
|
|
907
|
+
instance.conditions.startTime = startTime;
|
|
908
|
+
resetTime = false;
|
|
909
|
+
instance.conditions.resetTime = resetTime;
|
|
910
|
+
}
|
|
911
|
+
else {
|
|
912
|
+
progress = timestamp - startTime;
|
|
913
|
+
instance.conditions.progress = progress;
|
|
914
|
+
}
|
|
915
|
+
const progressInSeconds = progress / 1000;
|
|
916
|
+
const step = instance.route.steps[index];
|
|
917
|
+
if (step.coordinates.length <= 0) {
|
|
918
|
+
onFinish === null || onFinish === void 0 ? void 0 : onFinish(timestamp);
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
const start = step.coordinates[coordinatesIndex];
|
|
922
|
+
const end = step.coordinates[coordinatesIndex + 1];
|
|
923
|
+
if (start != null && end != null) {
|
|
924
|
+
if (rotatingIcon) {
|
|
925
|
+
const angle = NavFunctions.bearingInDegBetween(start, end);
|
|
926
|
+
if (iconRotationTime === 0 ||
|
|
927
|
+
instance.conditions.nextFloorFirstStepIndex === index ||
|
|
928
|
+
Math.abs(angle - instance.conditions.iconRotation) < 15) {
|
|
929
|
+
instance.conditions.nextFloorFirstStepIndex = undefined;
|
|
930
|
+
this.setMarkerRotation(instance, angle);
|
|
931
|
+
instance.conditions.startTime = timestamp;
|
|
932
|
+
instance.conditions.rotatingIcon = false;
|
|
933
|
+
instance.conditions.iconRotation = angle;
|
|
934
|
+
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
else if (progressInSeconds < iconRotationTime) {
|
|
938
|
+
const intermediateAngle = NavFunctions.intermediateAngleBetween(iconRotation, angle, progressInSeconds / iconRotationTime);
|
|
939
|
+
this.setMarkerRotation(instance, intermediateAngle);
|
|
940
|
+
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
else {
|
|
944
|
+
this.setMarkerRotation(instance, angle);
|
|
945
|
+
instance.conditions.startTime = timestamp;
|
|
946
|
+
instance.conditions.rotatingIcon = false;
|
|
947
|
+
instance.conditions.iconRotation = angle;
|
|
948
|
+
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
const distance = NavFunctions.distance(start, end);
|
|
953
|
+
const speed = Math.max(step.distance / stepTime, minimumSpeed !== null && minimumSpeed !== void 0 ? minimumSpeed : 0);
|
|
954
|
+
if (speed * progressInSeconds > distance) {
|
|
955
|
+
instance.currentSourceData.geometry.coordinates.push([end.lng, end.lat]);
|
|
956
|
+
const source = this.map.getSource(instance.currentId);
|
|
957
|
+
source === null || source === void 0 ? void 0 : source.setData(instance.currentSourceData);
|
|
958
|
+
if (coordinatesIndex + 2 < step.coordinates.length) {
|
|
959
|
+
const next = step.coordinates[coordinatesIndex + 2];
|
|
960
|
+
if (!compareLatLng(end, next)) {
|
|
961
|
+
if (instance.conditions.isStepByStep) {
|
|
962
|
+
instance.conditions.rotatingIcon = true;
|
|
963
|
+
}
|
|
964
|
+
else {
|
|
965
|
+
const nextAngle = NavFunctions.bearingInDegBetween(end, next);
|
|
966
|
+
instance.conditions.iconRotation = nextAngle;
|
|
967
|
+
(_a = instance.routeMarker) === null || _a === void 0 ? void 0 : _a.setRotation(nextAngle);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
instance.conditions.startTime = timestamp;
|
|
971
|
+
instance.conditions.progress = 0;
|
|
972
|
+
instance.conditions.coordinatesIndex++;
|
|
973
|
+
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
else if (step.startInsideFloor !== step.endInsideFloor) {
|
|
977
|
+
if (waitStartTime == null) {
|
|
978
|
+
instance.conditions.waitStartTime = timestamp;
|
|
979
|
+
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
980
|
+
return;
|
|
981
|
+
}
|
|
982
|
+
if (timestamp - waitStartTime < changeFloorTime * 1000) {
|
|
983
|
+
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
else {
|
|
987
|
+
this.updatePlaceFloorForRouting(instance, step.endInsidePlace, step.endInsideFloor);
|
|
988
|
+
this.setMarkerLngLat(instance, step.endLocation);
|
|
989
|
+
instance.conditions.waitStartTime = undefined;
|
|
990
|
+
onFinish === null || onFinish === void 0 ? void 0 : onFinish(timestamp);
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
else {
|
|
995
|
+
onFinish === null || onFinish === void 0 ? void 0 : onFinish(timestamp);
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
const fraction = (speed * progressInSeconds) / distance;
|
|
1000
|
+
const point = distance === 0
|
|
1001
|
+
? end
|
|
1002
|
+
: NavFunctions.intermediatePointBetween(start, end, Math.min(fraction, 1));
|
|
1003
|
+
instance.currentSourceData.geometry.coordinates.push([point.lng, point.lat]);
|
|
1004
|
+
const source = this.map.getSource(instance.currentId);
|
|
1005
|
+
source === null || source === void 0 ? void 0 : source.setData(instance.currentSourceData);
|
|
1006
|
+
this.setMarkerLngLat(instance, point);
|
|
1007
|
+
(_b = instance.routeMarker) === null || _b === void 0 ? void 0 : _b.addTo(this.map);
|
|
1008
|
+
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1011
|
+
else {
|
|
1012
|
+
onFinish === null || onFinish === void 0 ? void 0 : onFinish(timestamp);
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
setMarkerLngLat(instance, point) {
|
|
1017
|
+
var _a, _b;
|
|
1018
|
+
if ((_a = instance.conditions) === null || _a === void 0 ? void 0 : _a.isStepByStep) {
|
|
1019
|
+
this.cameraFollow(instance, point);
|
|
1020
|
+
}
|
|
1021
|
+
(_b = instance.routeMarker) === null || _b === void 0 ? void 0 : _b.setLngLat(point);
|
|
1022
|
+
}
|
|
1023
|
+
setMarkerRotation(instance, angle) {
|
|
1024
|
+
var _a, _b, _c, _d;
|
|
1025
|
+
if ((_a = instance.conditions) === null || _a === void 0 ? void 0 : _a.isStepByStep) {
|
|
1026
|
+
this.mapvxMap.updateCamera({
|
|
1027
|
+
duration: (_b = instance.animationConfig) === null || _b === void 0 ? void 0 : _b.iconRotationTime,
|
|
1028
|
+
animate: true,
|
|
1029
|
+
bearing: angle,
|
|
1030
|
+
center: (_c = instance.routeMarker) === null || _c === void 0 ? void 0 : _c.getLngLat(),
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
return (_d = instance.routeMarker) === null || _d === void 0 ? void 0 : _d.setRotation(angle);
|
|
1034
|
+
}
|
|
1035
|
+
setMarkerFloor(floorId, routeId) {
|
|
1036
|
+
var _a;
|
|
1037
|
+
const instance = this.resolveInstance(routeId);
|
|
1038
|
+
(_a = instance === null || instance === void 0 ? void 0 : instance.routeMarker) === null || _a === void 0 ? void 0 : _a.setFloor(floorId);
|
|
1039
|
+
}
|
|
1040
|
+
cameraFollow(instance, point) {
|
|
1041
|
+
var _a, _b;
|
|
1042
|
+
this.mapvxMap.updateCamera({
|
|
1043
|
+
center: point,
|
|
1044
|
+
animate: true,
|
|
1045
|
+
bearing: (_a = instance.routeMarker) === null || _a === void 0 ? void 0 : _a.getRotation(),
|
|
1046
|
+
duration: (_b = instance.animationConfig) === null || _b === void 0 ? void 0 : _b.iconRotationTime,
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
//# sourceMappingURL=routeController.js.map
|