From 5edbd573f0ef47f156c5ecd4a9fecafeabda19ba Mon Sep 17 00:00:00 2001 From: Michael Parry Date: Wed, 17 Jul 2019 16:04:55 +0200 Subject: [PATCH] feat(cluster): update distance input Add distance cluster example. --- .../src/lib/sources/cluster.component.ts | 19 ++++++++++++++-- src/app/cluster/cluster.component.ts | 22 ++++++++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/projects/ngx-openlayers/src/lib/sources/cluster.component.ts b/projects/ngx-openlayers/src/lib/sources/cluster.component.ts index 120c0473..fb3d949d 100644 --- a/projects/ngx-openlayers/src/lib/sources/cluster.component.ts +++ b/projects/ngx-openlayers/src/lib/sources/cluster.component.ts @@ -1,4 +1,13 @@ -import { Component, Host, Input, forwardRef, ContentChild, AfterContentInit } from '@angular/core'; +import { + Component, + Host, + Input, + forwardRef, + ContentChild, + AfterContentInit, + SimpleChanges, + OnChanges, +} from '@angular/core'; import { Feature } from 'ol'; import { LayerVectorComponent } from '../layers/layervector.component'; import { SourceComponent } from './source.component'; @@ -13,7 +22,7 @@ import { Point } from 'ol/geom'; `, providers: [{ provide: SourceComponent, useExisting: forwardRef(() => SourceClusterComponent) }], }) -export class SourceClusterComponent extends SourceComponent implements AfterContentInit { +export class SourceClusterComponent extends SourceComponent implements AfterContentInit, OnChanges { instance: Cluster; @Input() @@ -37,4 +46,10 @@ export class SourceClusterComponent extends SourceComponent implements AfterCont this.instance = new Cluster(this); this.host.instance.setSource(this.instance); } + + ngOnChanges(changes: SimpleChanges) { + if (this.instance && changes.hasOwnProperty('distance')) { + this.instance.setDistance(this.distance); + } + } } diff --git a/src/app/cluster/cluster.component.ts b/src/app/cluster/cluster.component.ts index 6f318902..f77fa91d 100644 --- a/src/app/cluster/cluster.component.ts +++ b/src/app/cluster/cluster.component.ts @@ -29,7 +29,6 @@ import { Component, OnInit } from '@angular/core'; - @@ -52,7 +51,28 @@ import { Component, OnInit } from '@angular/core'; + +
+ Distance : + + ({{ distance }}) +
`, + styles: [ + ` + aol-map { + display: block; + height: calc(100% - 250px); + } + + .control { + display: flex; + align-items: center; + justify-content: flex-start; + margin: 20px; + } + `, + ], }) export class ClusterComponent implements OnInit { distance = 60;