forked from MapComplete/MapComplete
Feature: more or less working version of clustering, clusters of multiple layers are joined
This commit is contained in:
parent
5bc8f11d24
commit
0048c091d0
9 changed files with 143 additions and 65 deletions
|
|
@ -18,9 +18,10 @@ import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
|||
import NearbyFeatureSource from "../../Logic/FeatureSource/Sources/NearbyFeatureSource"
|
||||
import {
|
||||
SummaryTileSource,
|
||||
SummaryTileSourceRewriter,
|
||||
SummaryTileSourceRewriter
|
||||
} from "../../Logic/FeatureSource/TiledFeatureSource/SummaryTileSource"
|
||||
import { ShowDataLayerOptions } from "../../UI/Map/ShowDataLayerOptions"
|
||||
import { ClusterGrouping } from "../../Logic/FeatureSource/TiledFeatureSource/ClusteringFeatureSource"
|
||||
|
||||
export class WithSpecialLayers extends WithChangesState {
|
||||
readonly favourites: FavouritesFeatureSource
|
||||
|
|
@ -61,6 +62,7 @@ export class WithSpecialLayers extends WithChangesState {
|
|||
this.closestFeatures.registerSource(this.favourites, "favourite")
|
||||
|
||||
this.featureSummary = this.setupSummaryLayer()
|
||||
this.setupClusterLayer()
|
||||
this.initActorsSpecialLayers()
|
||||
this.drawSelectedElement()
|
||||
this.drawSpecialLayers()
|
||||
|
|
@ -128,6 +130,18 @@ export class WithSpecialLayers extends WithChangesState {
|
|||
return source
|
||||
}
|
||||
|
||||
/**
|
||||
* On high zoom levels, the clusters will be gathered in the GroupClustering.
|
||||
* This method is responsible for drawing it
|
||||
* @private
|
||||
*/
|
||||
private setupClusterLayer(): void {
|
||||
new ShowDataLayer(this.map, {
|
||||
features: ClusterGrouping.singleton,
|
||||
layer: new LayerConfig(<LayerConfigJson>(<unknown>summaryLayer), "summaryLayer")
|
||||
})
|
||||
}
|
||||
|
||||
protected registerSpecialLayer(flayer: FilteredLayer, source: FeatureSource) {
|
||||
if (!source?.features) {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -53,11 +53,20 @@ export class Tiles {
|
|||
|
||||
/**
|
||||
* Returns the centerpoint [lon, lat] of the specified tile
|
||||
* @param z
|
||||
* @param z OR tileId
|
||||
* @param x
|
||||
* @param y
|
||||
*/
|
||||
static centerPointOf(z: number, x: number, y: number): [number, number] {
|
||||
static centerPointOf(z: number, x: number, y: number): [number, number] ;
|
||||
static centerPointOf(tileId: number): [number, number] ;
|
||||
|
||||
static centerPointOf(zOrId: number, x?: number, y?: number): [number, number] {
|
||||
let z: number
|
||||
if (x === undefined) {
|
||||
[z, x, y] = Tiles.tile_from_index(zOrId)
|
||||
} else {
|
||||
z = zOrId
|
||||
}
|
||||
return [
|
||||
(Tiles.tile2long(x, z) + Tiles.tile2long(x + 1, z)) / 2,
|
||||
(Tiles.tile2lat(y, z) + Tiles.tile2lat(y + 1, z)) / 2,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue