|
1 | 1 | import { format, sub } from 'date-fns'; |
2 | 2 | import bbox from '@turf/bbox'; |
3 | 3 |
|
4 | | -import { utcDate } from '../../../utils/utils'; |
5 | | - |
6 | 4 | const dateFormats = { |
7 | 5 | monthOnly: 'MM', |
8 | 6 | month: 'yyyyMM', |
@@ -208,8 +206,7 @@ export const layerTypes = { |
208 | 206 |
|
209 | 207 | // The source we're updating is not present. |
210 | 208 | if (!mbMap.getSource(vecId) || !mbMap.getSource(rastId)) return; |
211 | | - |
212 | | - const formatDate = format(utcDate(date), dateFormats[layerInfo.timeUnit]); |
| 209 | + const formatDate = format(date, dateFormats[layerInfo.timeUnit]); |
213 | 210 | const vectorData = source.data.replace('{date}', formatDate); |
214 | 211 | const rasterTiles = backgroundSource.tiles.map(tile => tile.replace('{date}', formatDate)); |
215 | 212 |
|
@@ -241,17 +238,19 @@ export const layerTypes = { |
241 | 238 | } |
242 | 239 | }, |
243 | 240 | show: (ctx, layerInfo) => { |
244 | | - const { mbMap } = ctx; |
245 | | - const { id, source, backgroundSource, domain } = layerInfo; |
| 241 | + const { props, mbMap } = ctx; |
| 242 | + const { date } = props; |
| 243 | + const { id, source, backgroundSource } = layerInfo; |
246 | 244 | const vecId = `${id}-vector`; |
247 | 245 | const rastId = `${id}-raster`; |
| 246 | + if (!date) return; |
248 | 247 |
|
249 | 248 | const inferPaint = { |
250 | 249 | 'line-color': '#f2a73a', |
251 | 250 | 'line-opacity': 0.8, |
252 | 251 | 'line-width': 2 |
253 | 252 | }; |
254 | | - const formatDate = format(utcDate(domain[domain.length - 1]), dateFormats[layerInfo.timeUnit]); |
| 253 | + const formatDate = format(date, dateFormats[layerInfo.timeUnit]); |
255 | 254 | const vectorL = { |
256 | 255 | ...source, |
257 | 256 | data: source.data.replace('{date}', formatDate) |
|
0 commit comments