@evergis/sgis
Advanced tools
Comparing version 0.5.0-alpha.8 to 0.5.0-alpha.9
@@ -7,4 +7,3 @@ import { Layer, LayerConstructorParams } from './Layer'; | ||
import { FeatureGroup } from '../features/FeatureGroup'; | ||
import { IClusterProvider } from "./clusterProviders/GridClusterProvider"; | ||
import { Handler } from "../EventHandler"; | ||
import { IClusterProvider } from "./clusterProviders/types"; | ||
export interface ClusterLayerConstructorParams extends LayerConstructorParams { | ||
@@ -20,3 +19,2 @@ clusterSymbol?: Symbol<Feature>; | ||
private _gridClusterProvider; | ||
private _clusterEventHandlers; | ||
private _clusters; | ||
@@ -29,4 +27,2 @@ /** | ||
getFeatures(bbox: Bbox, resolution: number): FeatureGroup[]; | ||
addClusterEvent(type: string, handler: Handler): void; | ||
removeClusterEvent(type: string, handler: Handler): void; | ||
/** | ||
@@ -33,0 +29,0 @@ * Adds a feature or an array of features to the layer. |
@@ -15,3 +15,2 @@ import { Layer } from './Layer'; | ||
super({ delayedUpdate, ...layerParams }); | ||
this._clusterEventHandlers = []; | ||
this._clusters = []; | ||
@@ -32,3 +31,2 @@ this._clusterSymbol = clusterSymbol; | ||
else { | ||
this._clusterEventHandlers.forEach(({ type, handler }) => !cluster.hasListener(type, handler) && cluster.on(type, handler)); | ||
renders = renders.concat(cluster.render(resolution, bbox.crs)); | ||
@@ -51,10 +49,2 @@ } | ||
} | ||
addClusterEvent(type, handler) { | ||
this._clusterEventHandlers.push({ type, handler }); | ||
} | ||
removeClusterEvent(type, handler) { | ||
const index = this._clusterEventHandlers.findIndex(item => item.type === type && item.handler === handler); | ||
this._clusterEventHandlers.splice(index, 1); | ||
this._clusters.forEach(cluster => cluster.off(type, handler)); | ||
} | ||
/** | ||
@@ -61,0 +51,0 @@ * Adds a feature or an array of features to the layer. |
import { FeatureGroup } from "../../features/FeatureGroup"; | ||
import { Bbox } from "../../Bbox"; | ||
import { Feature } from "../../features/Feature"; | ||
export interface IClusterProvider { | ||
getClusters(bbox: Bbox, resolution: number): FeatureGroup[]; | ||
add(features: Feature | Feature[]): void; | ||
remove(features: Feature | Feature[]): void; | ||
has(feature: Feature): boolean; | ||
} | ||
import { IClusterProvider, ClusterProviderParams, OnChangeGrid } from "./types"; | ||
export declare class GridClusterProvider implements IClusterProvider { | ||
@@ -16,3 +11,4 @@ readonly _features: Feature[]; | ||
private _cache; | ||
constructor(size?: number, distance?: number); | ||
readonly _onChangeGrid: OnChangeGrid; | ||
constructor({size, distance, onChangeGrid}?: ClusterProviderParams); | ||
private getDistanceGrid(grid, bbox, resolution); | ||
@@ -19,0 +15,0 @@ getClusters(bbox: Bbox, resolution: number): FeatureGroup[]; |
@@ -5,3 +5,3 @@ import { FeatureGroup } from "../../features/FeatureGroup"; | ||
export class GridClusterProvider { | ||
constructor(size = 88, distance) { | ||
constructor({ size = 88, distance, onChangeGrid } = {}) { | ||
this._features = []; | ||
@@ -12,2 +12,3 @@ this._size = size; | ||
this._distance = distance; | ||
this._onChangeGrid = onChangeGrid; | ||
} | ||
@@ -46,3 +47,3 @@ getDistanceGrid(grid, bbox, resolution) { | ||
getClusters(bbox, resolution) { | ||
if (this._resolution !== resolution) { | ||
if (this._resolution !== resolution || this._cache.length === 0) { | ||
this._cache = []; | ||
@@ -70,2 +71,3 @@ this._resolution = resolution; | ||
} | ||
this._onChangeGrid && this._onChangeGrid(this._cache); | ||
} | ||
@@ -72,0 +74,0 @@ return this._cache.filter(feature => feature.crs.canProjectTo(bbox.crs) && |
@@ -63,4 +63,4 @@ import { PolyControl } from "./controls/PolyControl"; | ||
export { Control } from "./controls/Control"; | ||
export declare const version = "0.5.0-alpha.8"; | ||
export declare const releaseDate = "19.08.2020"; | ||
export declare const version = "0.5.0-alpha.9"; | ||
export declare const releaseDate = "16.09.2020"; | ||
export declare const controls: { | ||
@@ -67,0 +67,0 @@ Circle: typeof Circle; |
@@ -65,4 +65,4 @@ import { PolyControl } from "./controls/PolyControl"; | ||
export { Control } from "./controls/Control"; | ||
export const version = "0.5.0-alpha.8"; | ||
export const releaseDate = "19.08.2020"; | ||
export const version = "0.5.0-alpha.9"; | ||
export const releaseDate = "16.09.2020"; | ||
let utilsModulesExt = {}; | ||
@@ -69,0 +69,0 @@ Object.assign(utilsModulesExt, utilsModule, { Color: Color }); |
{ | ||
"name": "@evergis/sgis", | ||
"version": "0.5.0-alpha.8", | ||
"version": "0.5.0-alpha.9", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/sGis_bundle.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
179
30186
2516295