@igo2/core
Version:
94 lines (89 loc) • 3.16 kB
JavaScript
import * as i0 from '@angular/core';
import { InjectionToken, inject, Injectable } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
const ROUTE_OPTIONS = {
languageKey: 'lang',
searchKey: 'search',
searchGeomKey: 'searchGeom',
exactMatchKey: 'exactMatch',
zoomExtentKey: 'zoomExtent',
focusFirstResultKey: 'sf',
toolKey: 'tool',
directionsCoordKey: 'routing',
directionsOptionsKey: 'routingOptions',
sidenavKey: 'sidenav',
visibleOnLayersKey: 'visiblelayers',
visibleOffLayersKey: 'invisiblelayers',
vectorKey: 'vector'
};
const LEGACY_ROUTE_OPTIONS = {
projectionKey: 'projection',
rotationKey: 'rotation',
zoomKey: 'zoom',
centerKey: 'center',
contextKey: 'context',
layersKey: 'layers',
wmsUrlKey: 'wmsUrl',
wmsLayersKey: 'wmsLayers',
wmtsUrlKey: 'wmtsUrl',
wmtsLayersKey: 'wmtsLayers',
arcgisUrlKey: 'arcgisUrl',
arcgisLayersKey: 'arcgisLayers',
iarcgisUrlKey: 'iarcgisUrl',
iarcgisLayersKey: 'iarcgisLayers',
tarcgisUrlKey: 'tarcgisUrl',
tarcgisLayersKey: 'tarcgisLayers'
};
const ROUTE_SERVICE_OPTIONS = new InjectionToken('routeServiceOptions');
function provideRouteServiceOptions(options) {
return {
provide: ROUTE_SERVICE_OPTIONS,
useValue: options
};
}
class RouteService {
router = inject(Router);
route = inject(ActivatedRoute);
options;
/**
* @deprecated use the new option of context-service
*/
legacyOptions;
constructor() {
const configs = inject(ROUTE_SERVICE_OPTIONS, {
optional: true
});
this.options = { ...ROUTE_OPTIONS, ...configs };
this.legacyOptions = LEGACY_ROUTE_OPTIONS;
}
get queryParams() {
let url = decodeURIComponent(location.search);
if (url.includes('¢er=')) {
url = url.replace('¢er', '¢er');
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: "20.3.19", ngImport: i0, type: RouteService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: RouteService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: RouteService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}], ctorParameters: () => [] });
/**
* Generated bundle index. Do not edit.
*/
export { LEGACY_ROUTE_OPTIONS, ROUTE_OPTIONS, ROUTE_SERVICE_OPTIONS, RouteService, provideRouteServiceOptions };
//# sourceMappingURL=igo2-core-route.mjs.map