-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestingLayout.html
More file actions
105 lines (93 loc) · 2.56 KB
/
Copy pathTestingLayout.html
File metadata and controls
105 lines (93 loc) · 2.56 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>H2OnMyWay</title>
<style>
#map{
height:400px;
width:100%;
}
</style>
</head>
<body>
<h1>H2OnMyWay</h1>
<div id="map"></div>
<script>
function initMap(){
// Map options
var options = {
zoom:8,
center:{lat:42.3601,lng:-71.0589}
}
// New map
var map = new google.maps.Map(document.getElementById('map'), options);
// Listen for click on map
google.maps.event.addListener(map, 'click', function(event){
// Add marker
addMarker({coords:event.latLng});
});
/*
// Add marker
var marker = new google.maps.Marker({
position:{lat:42.4668,lng:-70.9495},
map:map,
icon:'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png'
});
var infoWindow = new google.maps.InfoWindow({
content:'<h1>Lynn MA</h1>'
});
marker.addListener('click', function(){
infoWindow.open(map, marker);
});
*/
// Array of markers
var markers = [
{
coords:{lat:42.4668,lng:-70.9495},
iconImage:'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png',
content:'<h1>Lynn MA</h1>'
},
{
coords:{lat:42.8584,lng:-70.9300},
content:'<h1>Amesbury MA</h1>'
},
{
coords:{lat:42.7762,lng:-71.0773}
}
];
// Loop through markers
for(var i = 0;i < markers.length;i++){
// Add marker
addMarker(markers[i]);
}
// Add Marker Function
function addMarker(props){
var marker = new google.maps.Marker({
position:props.coords,
map:map,
//icon:props.iconImage
});
// Check for customicon
if(props.iconImage){
// Set icon image
marker.setIcon(props.iconImage);
}
// Check content
if(props.content){
var infoWindow = new google.maps.InfoWindow({
content:props.content
});
marker.addListener('click', function(){
infoWindow.open(map, marker);
});
}
}
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAC8lMbRAkN-19kPYqNfCl_B9SwUoehAQ0 &callback=initMap"
async defer></script>
</body>
</html>