-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoogle_maps_api.html
91 lines (70 loc) · 2.56 KB
/
google_maps_api.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Google Maps API</title>
<style type="text/css">
#map-div {
width: 100%;
height: 500px;
border: 1px solid black;
}
</style>
</head>
<body>
<!--div to hold map-->
<div id="map-div"></div>
<!--Load the Google Maps API - insert key here-->
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCldIbw_8f8DsQzfRWLmG9WkOS7GCfVHnM"></script>
<!--Script to show address on map-->
<script type="text/javascript">
// (function() {
"use strict";
// Set our map options
var mapOptions = {
// Set the zoom level
zoom: 18,
// This sets the center of the map location
center: {
lat:40.00758099999999,
lng:-105.26594169999998
}
};
// Render the map
var map = new google.maps.Map(document.getElementById("map-div"), mapOptions);
// Set our address to geocode
var address = "2359 Arapahoe Ave, Boulder, CO 80303";
// Init geocoder object
var geocoder = new google.maps.Geocoder();
// Geocode our address
geocoder.geocode({ "address": address }, function (results, status) {
// Check for a successful result
if (status === google.maps.GeocoderStatus.OK) {
// Recenter the map over the address
map.setCenter(results[0].geometry.location);
} else {
// Show an error message with the status if our request fails
alert ("Geocoding was not successful - STATUS: " + status);
}
});
var tibetKitchen = { lat: 40.014872, lng: -105.263427 };
var marker = new google.maps.Marker({
position: tibetKitchen,
map: map
});
var infowindow = new google.maps.InfoWindow({
content:
"<ul>" +
"<li>Delicious, authentic Tibetan cuisine</li>" +
"<li>Cheap, affordable student prices</li>" +
"<li>Free chai with every meal</li>" +
"<ul>"
});
function openWindow() {
infowindow.open(map, marker)
}
marker.addListener("click", openWindow);
// })();
</script>
</body>
</html>