-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
70 lines (56 loc) · 1.97 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Responsive Google Map</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
#map-canvas {
width: 100vw;
height: 40vh;
}
</style>
</head>
<body>
<div id="map-canvas"></div>
<!-- <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" async defer></script> -->
<script src="https://maps.googleapis.com/maps/api/js?&callback=initMap" async defer></script>
<script>
function initMap() {
var myLatlng = new google.maps.LatLng(53.349838, -6.260204); // latitude/longitude
var mapOptions = {
zoom: 13, // higher number => closer
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false, // remove street view icon
mapTypeControl: false // remove map type tabs
}
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
animation: google.maps.Animation.DROP,
title: 'Dublin, capital of the Republic of Ireland' // title when hovered over marker
});
// click on marker to open url in new tab
google.maps.event.addListener(marker, 'click', function() {
window.open('http://www.dublincity.ie/', '_blank');
});
// keep marker in middle
var center;
function calculateCenter() {
center = map.getCenter();
}
google.maps.event.addDomListener(map, 'idle', function() {
calculateCenter();
});
google.maps.event.addDomListener(window, 'resize', function() {
map.setCenter(center);
});
}
</script>
</body>
</html>