🐛 Hide layer when adding a new love
This commit is contained in:
+13
-3
@@ -8,6 +8,7 @@ export const useData = () => {
|
|||||||
const [canUseGeolocation, setCanUseGeolocation] = useState(false);
|
const [canUseGeolocation, setCanUseGeolocation] = useState(false);
|
||||||
const [geoError, setGeoError] = useState(null);
|
const [geoError, setGeoError] = useState(null);
|
||||||
|
|
||||||
|
const [source, setSource] = useState([]);
|
||||||
const [layers, setLayers] = useState([]);
|
const [layers, setLayers] = useState([]);
|
||||||
|
|
||||||
const [isAddLoveOpened, setIsAddLoveOpened] = useState(false);
|
const [isAddLoveOpened, setIsAddLoveOpened] = useState(false);
|
||||||
@@ -47,9 +48,19 @@ export const useData = () => {
|
|||||||
(async () => {
|
(async () => {
|
||||||
const dataset = await getDataset();
|
const dataset = await getDataset();
|
||||||
|
|
||||||
|
setSource(dataset);
|
||||||
|
})();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isAddLoveOpened) {
|
||||||
|
setLayers([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const datasetLayer = new IconLayer({
|
const datasetLayer = new IconLayer({
|
||||||
id: 'lovePoints',
|
id: 'lovePoints',
|
||||||
data: dataset,
|
data: source,
|
||||||
iconAtlas: `data:image/svg+xml;charset=utf-8,${encodeURIComponent(
|
iconAtlas: `data:image/svg+xml;charset=utf-8,${encodeURIComponent(
|
||||||
StringifiedPinIcon()
|
StringifiedPinIcon()
|
||||||
)}`,
|
)}`,
|
||||||
@@ -70,8 +81,7 @@ export const useData = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setLayers([datasetLayer]);
|
setLayers([datasetLayer]);
|
||||||
})();
|
}, [source, isAddLoveOpened]);
|
||||||
}, []);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
deckRef,
|
deckRef,
|
||||||
|
|||||||
+8
-4
@@ -19,10 +19,10 @@ import HeartIcon from '@/assets/HeartIcon';
|
|||||||
import Input from '@/components/Input/Input';
|
import Input from '@/components/Input/Input';
|
||||||
import CloseIcon from '@/assets/CloseIcon';
|
import CloseIcon from '@/assets/CloseIcon';
|
||||||
import AddIcon from '@/assets/AddIcon';
|
import AddIcon from '@/assets/AddIcon';
|
||||||
import pin from '@/assets/pin.png';
|
|
||||||
import 'mapbox-gl/dist/mapbox-gl.css';
|
import 'mapbox-gl/dist/mapbox-gl.css';
|
||||||
import './styles.scss';
|
import './styles.scss';
|
||||||
import Loader from '@/assets/Loader';
|
import Loader from '@/assets/Loader';
|
||||||
|
import PinIcon from '@/assets/PinIcon';
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
@@ -89,9 +89,13 @@ const Home = () => {
|
|||||||
></Map>
|
></Map>
|
||||||
</DeckGL>
|
</DeckGL>
|
||||||
{isAddLoveOpened && (
|
{isAddLoveOpened && (
|
||||||
<Image
|
// <Image
|
||||||
src={pin}
|
// src={pin}
|
||||||
alt='pin'
|
// alt='pin'
|
||||||
|
// width={30}
|
||||||
|
// className='pinImage'
|
||||||
|
// />
|
||||||
|
<PinIcon
|
||||||
width={30}
|
width={30}
|
||||||
className='pinImage'
|
className='pinImage'
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const PinIcon = (props) => {
|
|||||||
x='0px'
|
x='0px'
|
||||||
y='0px'
|
y='0px'
|
||||||
viewBox='0 0 100 100'
|
viewBox='0 0 100 100'
|
||||||
|
fill='#d94253'
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<g>
|
<g>
|
||||||
|
|||||||
Reference in New Issue
Block a user