mirror of
https://github.com/owntracks/recorder.git
synced 2026-05-05 02:36:45 +00:00
add autozoom toggle to map
This commit is contained in:
@@ -26,6 +26,44 @@ function initialize() {
|
||||
};
|
||||
|
||||
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
|
||||
|
||||
/* Create the DIV to hold the control and call constructor */
|
||||
var buttonControlDiv = document.createElement('div');
|
||||
var buttonControl = new ButtonControl(buttonControlDiv, map);
|
||||
|
||||
buttonControlDiv.index = 1;
|
||||
map.controls[google.maps.ControlPosition.BOTTOM_LEFT].push(buttonControlDiv);
|
||||
}
|
||||
|
||||
function ButtonControl(controlDiv, map) {
|
||||
|
||||
// Set CSS for the control border.
|
||||
var controlUI = document.createElement('div');
|
||||
controlUI.style.backgroundColor = '#fff';
|
||||
controlUI.style.border = '2px solid #fff';
|
||||
controlUI.style.borderRadius = '3px';
|
||||
controlUI.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)';
|
||||
controlUI.style.cursor = 'pointer';
|
||||
controlUI.style.marginBottom = '22px';
|
||||
controlUI.style.textAlign = 'center';
|
||||
controlUI.title = 'Click to toggle Autozoom (zoom to fit)';
|
||||
controlDiv.appendChild(controlUI);
|
||||
|
||||
// Set CSS for the control interior.
|
||||
var controlText = document.createElement('div');
|
||||
controlText.style.color = 'rgb(25,25,25)';
|
||||
controlText.style.fontFamily = 'Roboto,Arial,sans-serif';
|
||||
controlText.style.fontSize = '16px';
|
||||
controlText.style.lineHeight = '38px';
|
||||
controlText.style.paddingLeft = '5px';
|
||||
controlText.style.paddingRight = '5px';
|
||||
controlText.innerHTML = 'Autozoom';
|
||||
controlUI.appendChild(controlText);
|
||||
|
||||
// Setup the click event listeners: simply set the map to Chicago.
|
||||
controlUI.addEventListener('click', function() {
|
||||
do_fit = !do_fit;
|
||||
});
|
||||
}
|
||||
|
||||
function clog(upd, id, s) {
|
||||
|
||||
Reference in New Issue
Block a user