Week 7: MapBox API

To Do This Week:

E-lit Projects (DUE Wednesday, Oct 8th) Final Submission Instructions:

Intro: GitHub CoPilot

Optional switch to use the professional developer workspace combining CoPilot and GitHub

Map Story (15%)

DUE October 22

For this project, you'll be creating a  web-based storytelling experience that uses the Mapbox API to convey a narrative through geographical markers. This project requires a blend of creative storytelling, technical web development skills, and a thoughtful integration of multimedia elements. Follow these structured guidelines, using the MapBox API resources and examples as well as ChatGPT for brainstorming, planning, and problem-solving throughout your project's development:

Project Statement:
Include a statement at the top of your <script>. This statement should:
Your Steps:
  1. Explore the MapBox API: What is possible? What are the interactive map techniques you want to work with?
  2. Theme and Storyline Ideation: Select a theme for your map-based narrative, such as a personal journey, historical exploration, or fictional adventure.
  3. Storyboarding Locations: Identify at least five key locations to serve as markers on your map. How will they be displayed? How will the user interact with these locations?
  4. Consultation with ChatGPT: Use ChatGPT to refine your storyline and ensure the technical feasibility of your plan with the Mapbox API and JavaScript.
  5. Interactive Design: Plan the Mapbox styles, the layout, JavaScript functions needed, including marker placement, customized popups, and multimedia integration.
  6. Implementing JavaScript and Mapbox API: Code your project with the MapBox API code samples, ensuring the HTML structure supports map and narrative elements. Use ChatGPT for JavaScript and Mapbox API assistance.
  7. Testing and Debugging: Test your map thoroughly, paying close attention to interactive features and multimedia playback.
  8. CSS Styling: Apply CSS to complement your narrative, ensuring the design enhances the storytelling experience.
  9. Integration Statement: In your source code comments, summarize your JavaScript steps and highlight ChatGPT’s role in your project.
  10. Final Submission: Place your index.html file in a folder called map, validate your HTML and CSS, upload the folder to the server, and submit the URL through Canvas.
Suggested Innovative Map Ideas:

JS Methods for the Map Project:

Key JavaScript methods for building your map: classList: Add or remove CSS classes for an element.
const reset = document.querySelector('button');
reset.classList.remove('show');
reset.classList.add('hide');
Get Started:
Sign in to Mapbox. You will need an API access token to configure maps. Follow the instructions on the site to get started.

How to Find Latitude and Longitude:

  1. Open Google Maps and search for a place.
  2. Right-click on the map and select “What’s Here?”
  3. The latitude and longitude will appear at the bottom. Click to copy the coordinates.
Custom Styles:
Example of an Interactive Map:

JSON (JavaScript Object Notation):

JSON is used for storing and exchanging data. Here’s an example of an object literal:
let meal = {
  vegetable: "peppers",
  protein: "chicken",
  carb: "rice",
  spicy: ["none", "mild", "medium", "hot"],
  country: {
    name: "Mexico",
    location: [lat, long]
  },
  expression: function() {
    alert("buen provecho!");
  }
};

meal.protein;          // returns "chicken"
meal.expression();     // alerts "buen provecho!"
meal.spicy[1];         // returns "mild"
meal.country.location[0]; // returns latitude
Learn more about JSON and objects:

Map Ideas:

Explore Mapbox GL JS examples.

Mapbox Styles:

Mapbox Styles Gallery | Mapbox Studio

Objects, JSON, and Mapbox:

Some Mapbox Examples

  1. Adding a Simple Map
  2. Add a Clickable Marker
  3. Add Multiple Markers
  4. Add Custom Icons with Markers
  5. Fly to a Location
  6. Display a Map on a Webpage
  7. Add 3D Terrain to a Map
  8. Display Navigation Directions
  9. Create a Draggable Marker
  10. Add a Geocoder (Search) Control
  11. Animate a Point Along a Route
  12. Display Real-Time Data
  13. Cluster Point Data
  14. Filter Features Within Map View
  15. Draw a Polygon
  16. Measure Distances

Design & Development Process:

  1. Choose a theme for your map-based narrative, such as a personal journey, historical exploration, or fictional adventure.
  2. Research MapBox API.  What is possible?
  3. Sketch or storyboard the interaction of YOUR map. What is the best way to experience your map theme?
  4. Gather geolocations on Google Maps (right/control click to get long/lat and remember to reverse for MapBox.
  5. Create HTML and basic CSS with colored borders for the elements in the Map Project. Consider using CSS Grid, Flexbox, or position-fixed to place elements.For fixed body heights (no overflow), add the following CSS:
    html, body {
      height: 100%;
      overflow: hidden;
    }
    
  6. Plan the JavaScript steps for what you need. Keep it simple, but be detailed. Don't list features of the map interface. Think sequentially. To start you need a Geojson to hold necessary info, you need variables, etc.Then you need to think about what happens when the user interacts. What has to happen? What functions do you need?
  7. Build the very basics of the JavaScript (no effects or complex arrays) to ensure functionality. Try starting with just 3 locations.
  8. Add animations or transition effects using the classList method with CSS Animations or CSS transitions.
  9. Add more markers, images, media, text, and graphic elements.
  10. Complete CSS design for visual hierarchy.
  11. Test/Troubleshoot

Custom Map Styles

Student Map Examples: