-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Source, Layer } from 'react-map-gl'; | ||
import { useSelector } from 'react-redux'; | ||
import React from 'react'; | ||
import type { FillLayer } from 'react-map-gl'; | ||
import { activeFilterSelector } from 'state/features/selectors'; | ||
import { FilterType } from 'types/Filters.types'; | ||
import useMapObjectState from '../providers/useMapObjectState'; | ||
|
||
const layerId = 'ekb-population-layer'; | ||
const sourceId = 'ekb-population-source'; | ||
|
||
export function PopulationSource() { | ||
const activeFilter = useSelector(activeFilterSelector); | ||
|
||
useMapObjectState(layerId); | ||
|
||
if (activeFilter !== FilterType.Population) { | ||
return null; | ||
} | ||
|
||
const layerStyle: FillLayer = { | ||
id: layerId, | ||
type: 'fill', | ||
source: sourceId, | ||
paint: { | ||
// @ts-ignore | ||
'fill-color': [ | ||
'interpolate', | ||
['linear'], | ||
['get', 'population'], | ||
0, | ||
'green', | ||
8000, | ||
'red', | ||
], | ||
'fill-opacity': 0.5, | ||
}, | ||
}; | ||
|
||
return ( | ||
<Source | ||
id={sourceId} | ||
data="https://map-backend.netlify.app/kontur-population.json" | ||
type="geojson" | ||
generateId | ||
> | ||
<Layer {...layerStyle} /> | ||
</Source> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82b9e69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for map ready!
✅ Preview
https://map-191kylezo-ekbdev.vercel.app
https://ekbdev-map-population.vercel.app
Built with commit 82b9e69.
This pull request is being automatically deployed with vercel-action