UNPKG

@igo2/core

Version:
82 lines (78 loc) 3.18 kB
import * as i0 from '@angular/core'; import { InjectionToken, Injectable, Inject, Optional } from '@angular/core'; import * as i1 from '@angular/router'; const ROUTE_SERVICE_OPTIONS = new InjectionToken('routeServiceOptions'); function provideRouteServiceOptions(options) { return { provide: ROUTE_SERVICE_OPTIONS, useValue: options }; } class RouteService { router; route; options; constructor(router, route, options) { this.router = router; this.route = route; const defaultOptions = { centerKey: 'center', zoomKey: 'zoom', projectionKey: 'projection', contextKey: 'context', searchKey: 'search', visibleOnLayersKey: 'visiblelayers', visibleOffLayersKey: 'invisiblelayers', directionsCoordKey: 'routing', directionsOptionsKey: 'routingOptions', toolKey: 'tool', wmsUrlKey: 'wmsUrl', wmsLayersKey: 'wmsLayers', wmtsUrlKey: 'wmtsUrl', wmtsLayersKey: 'wmtsLayers', arcgisUrlKey: 'arcgisUrl', arcgisLayersKey: 'arcgisLayers', iarcgisUrlKey: 'iarcgisUrl', iarcgisLayersKey: 'iarcgisLayers', tarcgisUrlKey: 'tarcgisUrl', tarcgisLayersKey: 'tarcgisLayers', vectorKey: 'vector' }; this.options = Object.assign({}, defaultOptions, options); } get queryParams() { let url = decodeURIComponent(location.search); if (url.includes('¢er=')) { url = url.replace('¢er', '&center'); const queryParams = url .slice(1) .split('&') .map((p) => p.split('=')) .reduce((obj, pair) => { const [key, value] = pair.map(decodeURIComponent); obj[key] = value; return obj; }, {}); this.router.navigate([], { queryParams }); } return this.route.queryParams; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RouteService, deps: [{ token: i1.Router }, { token: i1.ActivatedRoute }, { token: ROUTE_SERVICE_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RouteService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RouteService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: () => [{ type: i1.Router }, { type: i1.ActivatedRoute }, { type: undefined, decorators: [{ type: Inject, args: [ROUTE_SERVICE_OPTIONS] }, { type: Optional }] }] }); /** * Generated bundle index. Do not edit. */ export { ROUTE_SERVICE_OPTIONS, RouteService, provideRouteServiceOptions }; //# sourceMappingURL=igo2-core-route.mjs.map