Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
51 lines (45 sloc) 1.49 KB
<!DOCTYPE html>
<html>
<head>
<title>Google Tour</title>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
<script>
/** Creates a map that shows landmarks around Google. */
function createMap(){
const map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 37.422403, lng: -122.088073},
zoom: 15
});
addLandmark(map, 37.423829, -122.092154, 'Google West Campus', 'Google West Campus is home to YouTube and Maps.')
addLandmark(map, 37.421903, -122.084674, 'Stan the T-Rex', 'This is Stan, the T-Rex statue.')
addLandmark(map, 37.420919, -122.086619, 'Permanente Creek Trail', 'Permanente Creek Trail connects Google to a system of bike trails.');
}
/** Adds a marker that shows an info window when clicked. */
function addLandmark(map, lat, lng, title, description){
const marker = new google.maps.Marker({
position: {lat: lat, lng: lng},
map: map,
title: title
});
const infoWindow = new google.maps.InfoWindow({
content: description
});
marker.addListener('click', function() {
infoWindow.open(map, marker);
});
}
</script>
<style>
#map{
width: 500px;
height: 500px;
border: thin solid black;
}
</style>
</head>
<body onload="createMap();">
<h1>Google Tour</h1>
<p>Here are a few of my favorite places at Google!</p>
<div id="map"></div>
</body>
</html>
You can’t perform that action at this time.