11import VectorTileLayer from 'ol/layer/VectorTile'
22import { PMTilesVectorSource } from 'ol-pmtiles'
33import { Style , Circle , Fill , Stroke } from 'ol/style'
4- import { confidenceColor , discretizeConf } from '../utils.js'
4+ import {
5+ confidenceColor ,
6+ discretizeConf ,
7+ zoomTierFromResolution ,
8+ POI_DOT_BY_ZOOM ,
9+ } from '../utils.js'
510import { OSM_PMTILES_URL } from '../constants.js'
611
712// OSM filter keys that drive feature visibility. A feature is visible when at
@@ -39,7 +44,7 @@ export function updateOsmFilters(filtersObj) {
3944 if ( layer ) layer . changed ( )
4045}
4146
42- function osmTileStyle ( feature ) {
47+ function osmTileStyle ( feature , resolution ) {
4348 if ( enabledKeys . size === 0 ) return null
4449
4550 // Visibility: feature must have at least one enabled key set.
@@ -54,17 +59,20 @@ function osmTileStyle(feature) {
5459
5560 const conf = feature . get ( 'conf_mean' )
5661 const bucket = discretizeConf ( conf )
57- if ( ! styleCache [ bucket ] ) {
62+ const tier = zoomTierFromResolution ( resolution )
63+ const key = `${ bucket } |${ tier } `
64+ if ( ! styleCache [ key ] ) {
5865 const color = confidenceColor ( conf == null || isNaN ( conf ) ? null : conf )
59- styleCache [ bucket ] = new Style ( {
66+ const { radius, stroke } = POI_DOT_BY_ZOOM [ tier ]
67+ styleCache [ key ] = new Style ( {
6068 image : new Circle ( {
61- radius : 5 ,
69+ radius,
6270 fill : new Fill ( { color } ) ,
63- stroke : new Stroke ( { color : '#fff' , width : 1 } ) ,
71+ stroke : new Stroke ( { color : '#fff' , width : stroke } ) ,
6472 } ) ,
6573 } )
6674 }
67- return styleCache [ bucket ]
75+ return styleCache [ key ]
6876}
6977
7078/**
0 commit comments