All Stations Map

Home

Dataset Information

For this exercise, we will use data about train stations from the Metro North and Shore Line East rail systems in New York and Connecticut.

Write JavaScript code to process the provided trainStations variable to answer the questions below. Display the answers on the page in the designated places.

  1. See the provided a station selector dropdown menu (i.e the designated select element). Loop through the stations and dynamically create a new option element for each station. Use the station's abbreviation as the option value, and the stations's name as the option text.
  2. Create a function called updateMap. It should identify what station is currently selected from the dropdown menu, then lookup the corresponding station using a find operation, and finally display a corresponding marker on the map. The marker text should include the name of the station, as well as a hyperlink to the webpage providing more information about that station.
  3. Invoke the function when the page loads. This should display the default / first station (i.e. "Grand Central Station").
  4. Add an event listener to update the map when a new station is selected. As a result, you should be able to select different stations from the dropdown to see the corresponding info on the map.


Map