22
33import { bboxPolygon , booleanIntersects } from '@turf/turf' ;
44import { Feature } from 'geojson' ;
5+ import compact from 'lodash/compact' ;
6+ import flatMap from 'lodash/flatMap' ;
57import boroughBoundaries from './Borough Boundaries simplified.json' ;
68
79const LAYER_IDS = [
@@ -12,6 +14,8 @@ const LAYER_IDS = [
1214 'atlas-1930' ,
1315 'atlas-1956' ,
1416 'nyc-label' ,
17+ 'lot-label' ,
18+ 'block-label' ,
1519] as const ;
1620
1721type LayerId = typeof LAYER_IDS [ number ] ;
@@ -23,7 +27,8 @@ export type OverlayId =
2327 | 'district'
2428 | 'atlas-1916'
2529 | 'atlas-1930'
26- | 'atlas-1956' ;
30+ | 'atlas-1956'
31+ | 'bbl-label' ;
2732
2833const MANHATTAN_BOUNDS_GEOJSON = boroughBoundaries . features . find (
2934 ( feature ) => feature . properties [ 'boro_name' ] === 'Manhattan'
@@ -55,6 +60,7 @@ const overlaysToLayers: { [overlay in OverlayId]: LayerId[] } = {
5560 'atlas-1916' : [ 'atlas-1916' ] ,
5661 'atlas-1930' : [ 'atlas-1930' ] ,
5762 'atlas-1956' : [ 'atlas-1956' ] ,
63+ 'bbl-label' : [ 'block-label' , 'lot-label' ] ,
5864} ;
5965
6066const NYC_ATTRIBUTION =
@@ -155,9 +161,17 @@ export const installLayers = (
155161
156162export const setOverlay = (
157163 map : mapboxgl . Map ,
158- overlayId : OverlayId | null
164+ overlayId : OverlayId | null | OverlayId [ ]
159165) : void => {
160- const visibleLayers = overlayId ? overlaysToLayers [ overlayId ] : [ ] ;
166+ // If overlayId is not an arary, convert it to an array
167+ const overlayIds : OverlayId [ ] = compact (
168+ Array . isArray ( overlayId ) ? overlayId : [ overlayId ]
169+ ) ;
170+
171+ const visibleLayers = flatMap (
172+ overlayIds ,
173+ ( overlayId ) => overlaysToLayers [ overlayId ]
174+ ) ;
161175 const mapBounds = map . getBounds ( ) ;
162176
163177 // Convert the map bounds into a Turf polygon
0 commit comments