map.setOptions({
center: marker.getPosition(),
zoom: 17
});
var listeners = [];
document.getElementById('myCheckbox').addEventListener('change', function() {
if (this.checked) {
for (var i = 0; i < markers.length; i++) {
var listener = google.maps.event.addListener(markers[i], 'dblclick', function() {
map.setZoom(17);
map.panTo(this.getPosition());
});
listeners.push(listener);
}
} else {
for (var i = 0; i < listeners.length; i++) {
google.maps.event.removeListener(listeners[i]);
}
}
});