ogn-live/horizZoomControl.js

55 wiersze
1.8 KiB
JavaScript

/*
* 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);
}