@@ -8,7 +8,6 @@ import { useState, useEffect } from 'react';
88import { Plus } from 'lucide-react' ;
99import AddGistModal from './AddGistModal' ;
1010import { motion } from 'framer-motion' ;
11- import { useCluster } from './useCluster' ;
1211
1312export interface Gist {
1413 id : number ;
@@ -56,12 +55,6 @@ function ChangeView({
5655export default function Map ( ) {
5756 const [ position , setPosition ] = useState < [ number , number ] > ( [ 6.5244 , 3.3792 ] ) ;
5857 const [ gists , setGists ] = useState < Gist [ ] > ( [
59- ...Array . from ( { length : 110 } , ( _ , i ) => ( {
60- id : i + 10 ,
61- content : `Synthetic gist #${ i + 1 } for cluster testing` ,
62- lat : 6.5244 + ( Math . random ( ) - 0.5 ) * 0.04 ,
63- lng : 3.3792 + ( Math . random ( ) - 0.5 ) * 0.04 ,
64- } ) ) ,
6558 {
6659 id : 1 ,
6760 content : 'Amazing suya spot just opened here!' ,
@@ -76,27 +69,23 @@ export default function Map() {
7669 } ,
7770 ] ) ;
7871 const [ isModalOpen , setIsModalOpen ] = useState ( false ) ;
72+ const [ locationAnnouncement , setLocationAnnouncement ] = useState ( '' ) ;
7973
8074 useEffect ( ( ) => {
8175 navigator . geolocation . getCurrentPosition (
8276 ( pos ) => {
8377 const { latitude, longitude } = pos . coords ;
8478 setPosition ( [ latitude , longitude ] ) ;
79+ setLocationAnnouncement (
80+ `Map centered on ${ latitude . toFixed ( 4 ) } , ${ longitude . toFixed ( 4 ) } `
81+ ) ;
8582 } ,
8683 ( err ) => {
8784 console . warn ( `Geolocation Error (${ err . code } ): ${ err . message } ` ) ;
8885 }
8986 ) ;
9087 } , [ ] ) ;
9188
92- const ClusterWrapper = useCluster ( gists . length ) ;
93-
94- const gistMarkers = gists . map ( ( gist ) => (
95- < Marker key = { gist . id } position = { [ gist . lat , gist . lng ] } icon = { blueIcon } >
96- < Popup > { gist . content } </ Popup >
97- </ Marker >
98- ) ) ;
99-
10089 const handleAddGist = ( content : string ) => {
10190 const newGist : Gist = {
10291 id : Date . now ( ) ,
@@ -109,6 +98,9 @@ export default function Map() {
10998
11099 return (
111100 < div className = "relative h-full w-full" >
101+ < div aria-live = "polite" role = "status" className = "sr-only" >
102+ { locationAnnouncement }
103+ </ div >
112104 < MapContainer center = { position } zoom = { 14 } className = "h-full w-full" >
113105 < ChangeView center = { position } zoom = { 14 } />
114106 < TileLayer
@@ -118,7 +110,11 @@ export default function Map() {
118110 < Marker position = { position } icon = { greenIcon } >
119111 < Popup > Your Current Location</ Popup >
120112 </ Marker >
121- { ClusterWrapper ? < ClusterWrapper > { gistMarkers } </ ClusterWrapper > : gistMarkers }
113+ { gists . map ( ( gist ) => (
114+ < Marker key = { gist . id } position = { [ gist . lat , gist . lng ] } icon = { blueIcon } >
115+ < Popup > { gist . content } </ Popup >
116+ </ Marker >
117+ ) ) }
122118 </ MapContainer >
123119
124120 < motion . button
@@ -142,4 +138,4 @@ export default function Map() {
142138 />
143139 </ div >
144140 ) ;
145- }
141+ }
0 commit comments