Skip to content

Instantly share code, notes, and snippets.

@LuffyAnshul
Created April 1, 2021 17:17
Show Gist options
  • Save LuffyAnshul/8ba246f001e5d02d5c1072e927a678eb to your computer and use it in GitHub Desktop.
Save LuffyAnshul/8ba246f001e5d02d5c1072e927a678eb to your computer and use it in GitHub Desktop.
WildFire Tracker Map JS File
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