Disclaimers:
You are NOT required to use replit.com. You are welcome to use any other platform that allows you to code and host your website.
If you are not very familiar with programming or simply want to try out a new platform, we recommend replit.com. The instructions provided are tailored specifically for replit users, but any participants, no matter what platform they use, should have no problem following along.
You do not need to follow exactly the instructions provided below. Just make sure your submission satisfies all the specified requirements before turning in.
2. Create a basic HTML page
In your index.html file:
Build a basic page with a title and headings inside the body:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>YOUR PAGE TITLE</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>YOUR MAP HEADING</h1>
<h2>YOUR NAME AND CLASS YEAR</h2>
<script src="script.js"></script>
</body>
</html>
Replace the green text
2. Add a Google Map to the page
In your index.html file:
Add a placeholder (a div element) for the map (after <h2>)
<div id="googleMap" style="width:100%;height:600px;"></div>
Replace the green text if necessary
In your script.js file:
Write a function to create a map and add markers to it:
function myMap() {
}
Inside the body (between the curly braces) of the newly created function:
Create a variable that specifies the map’s properties:
var mapProp = {center: new google.maps.LatLng(41.553058977514695, -99.38645631528847), zoom:4};
Create a map and assign properties to it:
var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
Replace the green text with the preferred center location's coordinates and zoom level for the map
How to get the coordinates of a specific location on Google Maps:
Type the name of the location in the search bar and hit Enter
Right click on the name of the location on the map and copy its coordinates
3. Insert your API key
Get your API key by following these instructions (under “Creating API Keys”)
In your index.html file:
Insert your API key by adding the following line of code:
<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=myMap"></script>
4. Add markers to the Map
In your script.js file:
Create a basic marker at a specific position (location) and assign it to your Map:
var marker1 = new google.maps.Marker({position: new google.maps.LatLng(37.779044559525346, -122.39650106924927), map: map});
Create a marker with an icon of your choice:
var marker2 = new google.maps.Marker({position: new google.maps.LatLng(34.11615908712739, -118.22472381138931), map: map, icon: "LINK TO ICON"});
Create a marker with an information window:
var marker3 = new google.maps.Marker({position: new google.maps.LatLng(42.37744775419678, -71.06367686592604), map: map});
var infoWindow = new google.maps.InfoWindow({content:"INFO WINDOW CONTENT"});
infoWindow.open(map, marker3);
Replace the green text
Add more markers to the map: refer to Resources below
Click on the each of the images below to visit the web pages.
Feel free to explore other options that the Google Maps API offers to customize your map and add code to improve the appearance of your website!
script.js