Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ function App() {

//Makes API call when zipcode entered
useEffect(() => {
if(currZip != null){
fetch("https://api.mobilize.us/v1/organizations/1316/events?timeslot_start=gte_now&zipcode=" + currZip)

fetch("https://warren-events.s3.amazonaws.com/data/events.json")
.then((res)=>res.json())
.then((data)=>setEvents(data['data']));
.then((data)=>setEvents(data));

//Reset states on new zipcode
setHoverEvent(null);
setLocFilt(null);

}
}, [currZip]);
}, []);

return (
<div className="app">
Expand Down
27 changes: 13 additions & 14 deletions src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export function Map(props){

//Called to set/unset location filter
function locationFilter(event, set){
console.log(event)

if(set){
props.selectLoc({
Expand Down Expand Up @@ -109,27 +108,27 @@ export function Map(props){
if(props.events != null){

//Initiates map's focus at the first event (typically the closest to the provided zipcode) with a valid lat & long position
let first = 0;
if (!('location' in props.events[first]) || !('location' in props.events[first]['location']) || !('latitude' in props.events[first]['location']['location'])) {
first++;
}
// let first = 0;
// if (!('location' in props.events[first]) || !('location' in props.events[first]['location']) || !('latitude' in props.events[first]['location']['location'])) {
// first++;
// }

var lat = props.events[first]['location']['location']['latitude'];
var long = props.events[first]['location']['location']['longitude'];
// var lat = props.events[first]['location']['location']['latitude'];
// var long = props.events[first]['location']['location']['longitude'];

if(center[0] !== lat || center[0] !== long){
setCenter([lat, long]);
setNewCenter(true);
}
// if(center[0] !== lat || center[0] !== long){
// setCenter([lat, long]);
// setNewCenter(true);
// }

var places = {};

props.events.forEach(function(event, index) {

if (index > 500) return;
//If has longitude and latitute
if ('location' in event && 'location' in event['location'] && 'latitude' in event['location']['location']) {

//Creates string key for {places} dictionary
//Creates string key for {places} dictionary
let str = event['location']['location']['latitude'] + "&" + event['location']['location']['longitude'];
//Creates or adds to a location - adds HTML code for event list for that location
if (str in places) {
Expand All @@ -139,7 +138,7 @@ export function Map(props){
}

}
});
});
setLocations(places);
}

Expand Down