-
Notifications
You must be signed in to change notification settings - Fork 1
/
03.html
74 lines (57 loc) · 2.13 KB
/
03.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<link rel="stylesheet" type="text/css" href="css/main.css">
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
</head>
<body>
<div id="map-canvas"/>
<script type="text/javascript" src="js/assert.js"></script>
<script type="text/javascript">
var MAX_ZOOM = 20;
var map;
var marker;
function initialize() {
// Initialize center, a LatLng object
// *** REPLACE null WITH YOUR CODE:
var center = new google.maps.LatLng(48.067, 12.863);
// Initialize mapOptions, a MapOptions object
// *** REPLACE null WITH YOUR CODE ***
var mapOptions = {
center: center,
zoom: 15
};
// Initialize map, a Map object
// *** REPLACE null WITH YOUR CODE ***
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
// Initialize marker, a Marker object positioned at the center of the map
// *** REPLACE null WITH YOUR CODE ***
marker = new google.maps.Marker({
position: map.getCenter(),
map: map,
title: 'Click to zoom'
});
// Add a listener that pans back to the marker when the center changes
// marker
// *** YOUR CODE HERE ***
google.maps.event.addListener(map, 'center_changed', panToMarker);
// Add a listener that increments zoom when the marker is clicked
// *** YOUR CODE HERE ***
google.maps.event.addListener(marker, 'click', incrementZoom);
}
function panToMarker() {
// 3 seconds after the center of the map has changed, pan back to the
// marker.
window.setTimeout(function() {
map.panTo(marker.getPosition());
}, 3000);
}
function incrementZoom() {
map.setZoom((map.getZoom() + 1) % MAX_ZOOM);
map.setCenter(marker.getPosition());
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</body>
</html>