@@ -26,8 +26,8 @@ async function initialize() {
2626 const PinElement = markerLibrary . PinElement ;
2727 // Create the map
2828 window . map = new google . maps . Map ( document . getElementById ( 'map-canvas' ) , {
29- zoom : 12 ,
30- center : new google . maps . LatLng ( 37.76173100956567 , - 122.4386811010743 ) ,
29+ zoom : 4 ,
30+ center : new google . maps . LatLng ( 39 , - 100 ) ,
3131 disableDefaultUI : true ,
3232 zoomControl : true ,
3333 mapId : 'c46bf4bc0e87c92b'
@@ -416,8 +416,13 @@ window.showUserLocation = async function () {
416416 * Utility class for managing event data
417417 */
418418class Events {
419- static CSV_URL = './events_BayArea.csv' ;
420- // static CSV_URL = 'https://19hz.info/events_BayArea.csv';
419+ static CSV_URLS = [
420+ './events_BayArea.csv' ,
421+ './events_DC.csv' ,
422+ './events_LosAngeles.csv' ,
423+ './events_Miami.csv' ,
424+ './events_Seattle.csv'
425+ ] ;
421426 static VENUES_URL = 'venues.json' ;
422427
423428 /**
@@ -696,19 +701,23 @@ class Events {
696701 * @returns {Promise }
697702 */
698703 async query ( ) {
699- console . log ( 'Fetching CSV from' , Events . CSV_URL ) ;
704+ console . log ( 'Fetching CSVs from' , Events . CSV_URLS ) ;
700705 console . log ( 'Loading venues from' , Events . VENUES_URL ) ;
701706
702- // Load both CSV and venues in parallel
703- const [ csvResponse , venuesResponse ] = await Promise . all ( [
704- fetch ( new Request ( Events . CSV_URL ) ) ,
705- fetch ( new Request ( Events . VENUES_URL ) )
706- ] ) ;
707+ // Load all CSVs and venues in parallel
708+ const fetchPromises = Events . CSV_URLS . map ( url => fetch ( new Request ( url ) ) ) ;
709+ const responses = await Promise . all ( [ ...fetchPromises , fetch ( new Request ( Events . VENUES_URL ) ) ] ) ;
707710
708- if ( ! csvResponse . ok ) {
709- const error = new Error ( `CSV Fetch Failed! ${ csvResponse . status } ` ) ;
710- error . response = csvResponse ;
711- throw error ;
711+ const csvResponses = responses . slice ( 0 , - 1 ) ;
712+ const venuesResponse = responses [ responses . length - 1 ] ;
713+
714+ // Check all CSV responses
715+ for ( let i = 0 ; i < csvResponses . length ; i ++ ) {
716+ if ( ! csvResponses [ i ] . ok ) {
717+ const error = new Error ( `CSV Fetch Failed for ${ Events . CSV_URLS [ i ] } : ${ csvResponses [ i ] . status } ` ) ;
718+ error . response = csvResponses [ i ] ;
719+ throw error ;
720+ }
712721 }
713722
714723 if ( ! venuesResponse . ok ) {
@@ -717,7 +726,8 @@ class Events {
717726 throw error ;
718727 }
719728
720- const csvText = await csvResponse . text ( ) ;
729+ // Get text from all CSV responses
730+ const csvTexts = await Promise . all ( csvResponses . map ( r => r . text ( ) ) ) ;
721731 const venues = await venuesResponse . json ( ) ;
722732
723733 console . log ( `Loaded ${ venues . length } venues` ) ;
@@ -729,15 +739,20 @@ class Events {
729739 venueMap . set ( normalizedName , venue ) ;
730740 } ) ;
731741
732- // Parse CSV
733- const rows = Events . parseCSV ( csvText ) ;
734- console . log ( `Parsed ${ rows . length } CSV rows` ) ;
742+ // Parse all CSVs and merge rows
743+ let allRows = [ ] ;
744+ csvTexts . forEach ( ( csvText , index ) => {
745+ const rows = Events . parseCSV ( csvText ) ;
746+ console . log ( `Parsed ${ rows . length } rows from ${ Events . CSV_URLS [ index ] } ` ) ;
747+ allRows = allRows . concat ( rows ) ;
748+ } ) ;
749+ console . log ( `Total rows from all CSVs: ${ allRows . length } ` ) ;
735750
736751 // Transform rows to events
737752 const events = [ ] ;
738753 const unmatchedVenues = new Set ( ) ;
739754
740- rows . forEach ( ( row , index ) => {
755+ allRows . forEach ( ( row , index ) => {
741756 // CSV structure:
742757 // 0: Date, 1: Title, 2: Genres, 3: Venue, 4: Time,
743758 // 5: Cost, 6: Age, 7: Artists, 8: URL1, 9: URL2, 10: Numeric
0 commit comments