Creators: jctr073 and danabase
Documentation date: 04/22/2015
Objective:
Display current and/or ongoing events in preferred categories (i.e. conventions, fitness) that are occurring… in the city and state of the user’s choice during a particular calendar date or between a set of dates. These parameters are completely optional, which will trigger a default result. Premise:
give users a choice of parameters to enter: location information from vague to specific (city level vs. street address level), date or time (from date x to date y, or just one date), and event category (live performance, sports, music, food, etc) pull data–in this case, listed events from Eventbrite plot each event as a marker on google maps, providing basic information on the event (venue name and address, time span) Process
This process can be divided into 6 parts, as we start in the events controller and continue through a javascript file.
-
Access the EventBrite client through an access-token, sending out a defined search customized by the user-generated parameters. The API will return a response, which the event controller’s search method will format into a JSON object with a respond_to function.
-
In the event that a user–after providing a satisfactory contribution of data compliant with our guidelines–clicks the search button, an ajax call is made. In this call, we specify the HTTP verb as “POST”, the URL as “/search.json,” the datatype as JSON, and the data as the values passed in parameters (category keywords, city, state, etc).
-
Contingent on receiving at least 1 object returned, we’ll create a map centered on the LatLng of the first event retrieved. Moving on, this function will call another function, loadEvents.
-
In loadEvents, we create an event array and loop through each element, subsequently calling 2 functions to harvest the associated data.
-
The first function called is writeEventListing, which passes in the DOM element and current event. We pull up the event’s logo, title, start and end dates and present them in the view.
-
The second function called, plotMapPoints, passes in the loop’s iteration variable, the map and current event as parameters. here, we create a marker for the current event, labeling it with a sequentially-generated number. To accomplish this dynamically the pin URL needs to be divided into two variables and re-attached with the iteration variable in the middle. An infoWindow is created, complete with content, whose values were pulled from the current event object. Finally event handlers dealing with mouse interactions with infoWindows wraps up the process.
rake doc:app.