blob: f817b70f53eb42ea23a5efd161f746ca598d1330 [file] [log] [blame]
/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import {CommonModule} from "@angular/common";
import {ModuleWithProviders, NgModule, Type} from "@angular/core";
import {Observable} from "rxjs";
import {LeafletCenterMarkerDirective, LeafletDirective, LeafletMarkerDirective} from "./directives";
import {LEAFLET_RESIZE_TOKEN} from "./leaflet-configuration.token";
import {StringToLatLngZoomPipe} from "./pipes";
@NgModule({
imports: [
CommonModule
],
declarations: [
LeafletCenterMarkerDirective,
LeafletDirective,
LeafletMarkerDirective,
StringToLatLngZoomPipe
],
exports: [
LeafletCenterMarkerDirective,
LeafletDirective,
LeafletMarkerDirective,
StringToLatLngZoomPipe
]
})
export class LeafletModule {
public static for<T extends { resize$: Observable<any> }>(resizeService: Type<T>): ModuleWithProviders {
return {
ngModule: LeafletModule,
providers: [
{
provide: LEAFLET_RESIZE_TOKEN,
useFactory: (service: T) => service.resize$,
deps: [resizeService]
}
]
};
}
}