-
Notifications
You must be signed in to change notification settings - Fork 71
/
horizZoomControl.js
54 lines (43 loc) · 1.76 KB
/
horizZoomControl.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
/*
* The ZoomControl adds horizontal [+/-] buttons for the map
* to replace the standard vertical one
*/
function ZoomControl(controlDiv, map) {
// Creating divs & styles for custom zoom control
controlDiv.style.padding = '10px';
// Set CSS for the control wrapper
var controlWrapper = document.createElement('div');
controlWrapper.style.cursor = 'pointer';
controlWrapper.style.width = '56px';
controlWrapper.style.height = '28px';
controlWrapper.style.backgroundImage = 'url("horizZoom.png")';
controlDiv.appendChild(controlWrapper);
// Set CSS for the zoomIn
var zoomInButton = document.createElement('div');
zoomInButton.style.float = "left";
zoomInButton.style.width = '28px';
zoomInButton.style.height = '28px';
controlWrapper.appendChild(zoomInButton);
// Set CSS for the zoomOut
var zoomOutButton = document.createElement('div');
zoomOutButton.style.float = "left";
zoomOutButton.style.width = '28px';
zoomOutButton.style.height = '28px';
controlWrapper.appendChild(zoomOutButton);
// Setup the click event listener - zoomIn
google.maps.event.addDomListener(zoomInButton, 'click', function() {
map.setZoom(map.getZoom() + 1);
});
// Setup the click event listener - zoomOut
google.maps.event.addDomListener(zoomOutButton, 'click', function() {
map.setZoom(map.getZoom() - 1);
});
}
function horizZoomControl_initialize() {
// Create the DIV to hold the control and call the ZoomControl() constructor
// passing in this DIV.
var zoomControlDiv = document.createElement('div');
var zoomControl = new ZoomControl(zoomControlDiv, map);
zoomControlDiv.index = 1;
map.controls[google.maps.ControlPosition.TOP_CENTER].push(zoomControlDiv);
}