Firstly, to control the zoom level, there is the setZoom() method, which you can call in the maps object, in your example the map variable.
map.setZoom(5);
but more for your other map update problem. I assume that the entire web page is being updated to update the contents of the map. I think you should investigate ajax calls to update the data on the map without refreshing the entire page.
You already have the database using the downloadUrl() method - now just put this on setInterval() and let the data be updated every 30 seconds to 1 minute.
I also suggest that you clear the marker map before adding new ones, otherwise you will have a memory leak that creates duplicate DOM elements every time the data is updated. I usually put marker references in an array, and then marker.setMap(null) over the array and run marker.setMap(null) , which removes the marker from the map.
EDIT with code snippet
using the above code snippet, try to do this work by dividing the code into separate functions, the download function and the update function, also make sure that you move map and infoWindow to the global area.
var map; var infoWindow; function load() { map = new google.maps.Map(document.getElementById("map"), { center: new google.maps.LatLng(47.6145, -122.3418), zoom: 14, mapTypeId: 'roadmap' }); infoWindow = new google.maps.InfoWindow; refresh(); } function refresh(){ downloadUrl("phpsqlajax_genxml2.php", function(data) { var xml = data.responseXML; var markers = xml.documentElement.getElementsByTagName("marker"); var bounds = new google.maps.LatLngBounds(); for (var i = 0; i < markers.length; i++) { var UID = markers[i].getAttribute("UID"); var type = markers[i].getAttribute("type"); var point = new google.maps.LatLng( parseFloat(markers[i].getAttribute("latitude")), parseFloat(markers[i].getAttribute("longitude"))); var html = "<b>" + UID + "</b> <br/>"; var icon = customIcons[type] || {}; var marker = new google.maps.Marker({ map: map, position: point, icon: icon.icon, shadow: icon.shadow }); bounds.extend(point); bindInfoWindow(marker, map, infoWindow, html); } map.fitBounds(bounds); }); } setInterval("refresh()",60000);
source share