Created
April 1, 2021 17:17
-
-
Save LuffyAnshul/8ba246f001e5d02d5c1072e927a678eb to your computer and use it in GitHub Desktop.
WildFire Tracker Map JS File
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
const API_KEY = 'YOUR_API_KEY'; | |
const Map = ({ eventData, center, zoom }) => { | |
const [locationInfo, setLocationInfo] = useState(null); | |
const markers = eventData.map(ev => { | |
if(ev.categories[0].id === 8) { | |
return <LocationMarker | |
lat={ev.geometries[0].coordinates[1]} | |
lng={ev.geometries[0].coordinates[0]} | |
onClick={() => setLocationInfo({ id: ev.id, title: ev.title })} | |
/> | |
} | |
return null; | |
}); | |
return ( | |
<div className="map"> | |
<GoogleMapReact | |
bootstrapURLKeys={{ key: API_KEY }} | |
defaultCenter={ center } | |
defaultZoom={ zoom } | |
> | |
{ markers } | |
</GoogleMapReact> | |
{ locationInfo && <LocationInfoBox info={locationInfo} /> } | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment