diff --git a/projects/common-map/src/fm-map/common-map.module.ts b/projects/common-map/src/fm-map/common-map.module.ts index 1facf4f..bab0d79 100644 --- a/projects/common-map/src/fm-map/common-map.module.ts +++ b/projects/common-map/src/fm-map/common-map.module.ts @@ -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 {HistogramDetailsComponent} from './components/legend/histogram-details/histogram-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): ActionReducer { const r = function(state, action) { @@ -147,7 +148,8 @@ export { ForSourceTask, ForPackage , ITemporalItemLayer, - TemporalItemLayer + TemporalItemLayer, + ifZoomToShowDirective } @NgModule({ @@ -199,7 +201,8 @@ export { PanToLocation, LayerSwitcher, HistogramDetailsComponent, - StatisticsDetailsComponent + StatisticsDetailsComponent, + ifZoomToShowDirective ], entryComponents: [ FeatureListComponent, @@ -251,7 +254,8 @@ export { FeatureListCroppingschemeComponent, FeatureListCropfieldComponent, FeatureListFeatureContainerComponent, - ZoomToExtentComponent + ZoomToExtentComponent, + ifZoomToShowDirective ], providers: [ FeatureIconService, diff --git a/projects/common-map/src/fm-map/components/if-zoom-to-show/if-zoom-to-show.directive.ts b/projects/common-map/src/fm-map/components/if-zoom-to-show/if-zoom-to-show.directive.ts new file mode 100644 index 0000000..587e1be --- /dev/null +++ b/projects/common-map/src/fm-map/components/if-zoom-to-show/if-zoom-to-show.directive.ts @@ -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,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; + } + } +} \ No newline at end of file