-
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.
Merge pull request #3 from Vizzuality/feature/markers-interactivity
Markers: interactivity
- Loading branch information
Showing
22 changed files
with
89 additions
and
39 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
File renamed without changes.
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
File renamed without changes.
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,24 @@ | ||
import GEOSJON from '@/constants/markers.json'; | ||
|
||
import MarkerItem from './item'; | ||
|
||
const Markers = () => { | ||
const FeatureCollection = GEOSJON as unknown as GeoJSON.FeatureCollection< | ||
GeoJSON.Point, | ||
{ | ||
category: string; | ||
} | ||
>; | ||
|
||
return ( | ||
<> | ||
{FeatureCollection.features.map((f) => { | ||
const { id } = f; | ||
|
||
return <MarkerItem key={id} {...f} />; | ||
})} | ||
</> | ||
); | ||
}; | ||
|
||
export default Markers; |
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,36 @@ | ||
import { useCallback } from 'react'; | ||
|
||
import { useRouter } from 'next/navigation'; | ||
|
||
import Marker from '@/components/map/layers/marker'; | ||
|
||
export type MarkerItemProps = GeoJSON.Feature< | ||
GeoJSON.Point, | ||
{ | ||
category: string; | ||
} | ||
>; | ||
|
||
const MarkerItem = ({ id, geometry, properties }: MarkerItemProps) => { | ||
const { push } = useRouter(); | ||
const { category } = properties; | ||
|
||
const handleClick = useCallback(() => { | ||
push(`/stories/${id}`); | ||
}, [push, id]); | ||
|
||
return ( | ||
<Marker | ||
key={id} | ||
longitude={geometry.coordinates[0]} | ||
latitude={geometry.coordinates[1]} | ||
onClick={handleClick} | ||
> | ||
<div className="flex flex-col"> | ||
<div className="text-xs font-bold">{category}</div> | ||
</div> | ||
</Marker> | ||
); | ||
}; | ||
|
||
export default MarkerItem; |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.