forked from gkovacs/psetparty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.html
63 lines (58 loc) · 1.99 KB
/
map.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBteJTTaKlmbnDq4OpxXOVesyalgxoWLJE&sensor=false">
</script>
<script type="text/javascript">
function addMarker(address, infotext) {
getLatLng(address, function(latlng) {
var marker = new google.maps.Marker({
'position': latlng,
})
var infoWindow = new google.maps.InfoWindow({
'content': infotext,
})
google.maps.event.addListener(marker, 'click', function() {
infoWindow.open(map, this)
})
marker.setMap(map)
})
}
function getLatLng(str, callback) {
geocoder.geocode({
'address': str,
'region': 'US',
'bounds': getMITLatLngBounds(),
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
console.log(results[0].geometry.location)
if (callback != null) callback(results[0].geometry.location)
}
})
}
function getMITLatLngBounds() {
return new google.maps.LatLngBounds(new google.maps.LatLng(42.3543643, -71.10349120000001), new google.maps.LatLng(42.3630281, 71.08594310000001))
}
function initialize() {
geocoder = new google.maps.Geocoder();
var mapOptions = {
center: new google.maps.LatLng(42.3590995, -71.0934608),
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>