-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.js
60 lines (51 loc) · 1.52 KB
/
map.js
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
/*
* declare map as a global variable
*/
var map;
/*
* use google maps api built-in mechanism to attach dom events
*/
var mapstuff = function () {
/*
* create map
*/
var map = new google.maps.Map(document.getElementById("map_div"), {
center: new google.maps.LatLng(33.808678, -117.918921),
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
/*
* create infowindow (which will be used by markers)
*/
var infoWindow = new google.maps.InfoWindow();
/*
* marker creater function (acts as a closure for html parameter)
*/
function createMarker(options, html) {
var marker = new google.maps.Marker(options);
if (html) {
google.maps.event.addListener(marker, "click", function () {
infoWindow.setContent(html);
infoWindow.open(options.map, this);
});
}
return marker;
}
/*
* add markers to map
*/
/*var marker0 = createMarker({
position: new google.maps.LatLng(33.808678, -117.918921),
map: map,
icon: "http://1.bp.blogspot.com/_GZzKwf6g1o8/S6xwK6CSghI/AAAAAAAAA98/_iA3r4Ehclk/s1600/marker-green.png"
}, "<h1>Marker 0</h1><p>This is the home marker.</p>");
var marker1 = createMarker({
position: new google.maps.LatLng(33.818038, -117.928492),
map: map
}, "<h1>Marker 1</h1><p>This is marker 1</p>");
var marker2 = createMarker({
position: new google.maps.LatLng(33.803333, -117.915278),
map: map
}, "<h1>Marker 2</h1><p>This is marker 2</p>");*/
}
google.maps.event.addDomListener(window, "load", mapstuff);