Implement *fm-map-ifZoomToShowdirective
This commit is contained in:
parent
2f5ffde4d9
commit
154bcba620
@ -67,6 +67,7 @@ import { PanToLocation} from './components/aol/pan-to-location/pan-to-location.c
|
|||||||
import {LayerSwitcher} from './components/layer-switcher/layer-switcher.component';
|
import {LayerSwitcher} from './components/layer-switcher/layer-switcher.component';
|
||||||
import {HistogramDetailsComponent} from './components/legend/histogram-details/histogram-details.component';
|
import {HistogramDetailsComponent} from './components/legend/histogram-details/histogram-details.component';
|
||||||
import {StatisticsDetailsComponent} from './components/legend/statistics-details/statistics-details.component';
|
import {StatisticsDetailsComponent} from './components/legend/statistics-details/statistics-details.component';
|
||||||
|
import { ifZoomToShowDirective} from './components/if-zoom-to-show/if-zoom-to-show.directive';
|
||||||
|
|
||||||
export function LocalStorageSync(reducer: ActionReducer<any>): ActionReducer<any> {
|
export function LocalStorageSync(reducer: ActionReducer<any>): ActionReducer<any> {
|
||||||
const r = function(state, action) {
|
const r = function(state, action) {
|
||||||
@ -147,7 +148,8 @@ export {
|
|||||||
ForSourceTask,
|
ForSourceTask,
|
||||||
ForPackage ,
|
ForPackage ,
|
||||||
ITemporalItemLayer,
|
ITemporalItemLayer,
|
||||||
TemporalItemLayer
|
TemporalItemLayer,
|
||||||
|
ifZoomToShowDirective
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@ -199,7 +201,8 @@ export {
|
|||||||
PanToLocation,
|
PanToLocation,
|
||||||
LayerSwitcher,
|
LayerSwitcher,
|
||||||
HistogramDetailsComponent,
|
HistogramDetailsComponent,
|
||||||
StatisticsDetailsComponent
|
StatisticsDetailsComponent,
|
||||||
|
ifZoomToShowDirective
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
FeatureListComponent,
|
FeatureListComponent,
|
||||||
@ -251,7 +254,8 @@ export {
|
|||||||
FeatureListCroppingschemeComponent,
|
FeatureListCroppingschemeComponent,
|
||||||
FeatureListCropfieldComponent,
|
FeatureListCropfieldComponent,
|
||||||
FeatureListFeatureContainerComponent,
|
FeatureListFeatureContainerComponent,
|
||||||
ZoomToExtentComponent
|
ZoomToExtentComponent,
|
||||||
|
ifZoomToShowDirective
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
FeatureIconService,
|
FeatureIconService,
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
import { Directive, ViewContainerRef,TemplateRef,OnInit,Input } from '@angular/core';
|
||||||
|
import { IItemLayer } from '../../models/item.layer';
|
||||||
|
import { MapComponent } from 'ngx-openlayers';
|
||||||
|
|
||||||
|
@Directive({
|
||||||
|
selector: '[fm-map-ifZoomToShow]',
|
||||||
|
})
|
||||||
|
export class ifZoomToShowDirective implements OnInit {
|
||||||
|
@Input('fm-map-ifZoomToShow') itemLayer$:IItemLayer;
|
||||||
|
|
||||||
|
constructor(private templateRef$: TemplateRef<any>,private viewContainerRef$: ViewContainerRef,private map$: MapComponent) { }
|
||||||
|
private hasView = false;
|
||||||
|
ngOnInit() {
|
||||||
|
let minZoom = this.itemLayer$.layer.getMinZoom();
|
||||||
|
let currentZoom = this.map$.instance.getView().getZoom();
|
||||||
|
|
||||||
|
if ( currentZoom < minZoom ) {
|
||||||
|
this.viewContainerRef$.createEmbeddedView(this.templateRef$);
|
||||||
|
this.hasView=true;
|
||||||
|
} else if (this.hasView) {
|
||||||
|
this.viewContainerRef$.clear();
|
||||||
|
this.hasView = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user