@@ -58,18 +58,18 @@ export default class PoiVectorTileLayer {
58
58
const layerFeature = layerData . feature ( index ) ;
59
59
60
60
[ [ layerFeature . geom ] ] = layerFeature . loadGeometry ( ) ;
61
- const feature = pick ( layerFeature , [ 'geom' , 'properties' ] ) ;
62
-
63
- if (
64
- ! PoiVectorTileLayer . visibleCategories [
65
- feature . properties . category3
66
- ]
67
- ) {
68
- return null ;
69
- }
70
- return feature ;
61
+ return pick ( layerFeature , [ 'geom' , 'properties' ] ) ;
71
62
} )
72
- . filter ( Boolean ) ;
63
+ . filter ( feature => {
64
+ const poiLayer = getLayerByCode (
65
+ feature . properties . category3 ,
66
+ this . config ,
67
+ ) ;
68
+ return (
69
+ PoiVectorTileLayer . visibleCategories [ poiLayer . code ] &&
70
+ this . tile . coords . z >= poiLayer . properties . layer . min_zoom
71
+ ) ;
72
+ } ) ;
73
73
74
74
this . features . forEach ( feature => {
75
75
const layerCode = feature . properties . category3 ;
@@ -78,26 +78,24 @@ export default class PoiVectorTileLayer {
78
78
if ( poiLayer ) {
79
79
const { icon, layer } = poiLayer . properties ;
80
80
81
- if ( this . tile . coords . z >= layer . min_zoom ) {
82
- const parser = new DOMParser ( ) ;
83
- const docs = parser . parseFromString ( icon . svg , 'image/svg+xml' ) ;
84
- const svgElement = docs . querySelector ( 'svg' ) ;
81
+ const parser = new DOMParser ( ) ;
82
+ const docs = parser . parseFromString ( icon . svg , 'image/svg+xml' ) ;
83
+ const svgElement = docs . querySelector ( 'svg' ) ;
85
84
86
- if ( svgElement ) {
87
- svgElement . id = `icon-${ layerCode } ` ;
88
- svgElement . style . zIndex = layer . priority ;
89
- svgElement . style . display = 'none' ;
85
+ if ( svgElement ) {
86
+ svgElement . id = `icon-${ layerCode } ` ;
87
+ svgElement . style . zIndex = layer . priority ;
88
+ svgElement . style . display = 'none' ;
90
89
91
- document . body . appendChild ( svgElement ) ;
90
+ document . body . appendChild ( svgElement ) ;
92
91
93
- drawIcon (
94
- `icon-${ feature . properties . category3 } ` ,
95
- this . tile ,
96
- feature . geom ,
97
- this . imageSize ,
98
- svgElement . style ,
99
- ) ;
100
- }
92
+ drawIcon (
93
+ `icon-${ feature . properties . category3 } ` ,
94
+ this . tile ,
95
+ feature . geom ,
96
+ this . imageSize ,
97
+ svgElement . style ,
98
+ ) ;
101
99
}
102
100
}
103
101
} ) ;
0 commit comments