function init_gmap() { var DEFAULT_ZOOM = 6; var bounds = new google.maps.LatLngBounds(); var myOptions = { zoom: DEFAULT_ZOOM, mapTypeId: google.maps.MapTypeId.HYBRID }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var icon_red = '/images/markers/rain_red.png'; var icon_yellow = '/images/markers/rain_yellow.png'; var markers = [{"title":"Arequipa","type":"station","lat":-16.3167,"long":-71.55,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Arequipa,Peru"},{"title":"Cajamarca","type":"station","lat":-7.1333,"long":-78.4667,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Cajamarca,Peru"},{"title":"Chiclayo","type":"station","lat":-6.7833,"long":-79.8333,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Chiclayo,Peru"},{"title":"Chimbote","type":"station","lat":-9.1667,"long":-78.5167,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Chimbote,Peru"},{"title":"Cusco","type":"station","lat":-13.55,"long":-71.9833,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Cusco,Peru"},{"title":"Huanuco","type":"station","lat":-9.9,"long":-75.75,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Huanuco,Peru"},{"title":"Iquitos","type":"station","lat":-3.75,"long":-73.25,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Iquitos,Peru"},{"title":"Juliaca","type":"station","lat":-15.4833,"long":-70.15,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Juliaca,Peru"},{"title":"Lima","type":"station","lat":-12,"long":-77.1167,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Lima,Peru"},{"title":"Pisco","type":"station","lat":-13.75,"long":-76.2833,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Pisco,Peru"},{"title":"Piura","type":"station","lat":-5.1833,"long":-80.6,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Piura,Peru"},{"title":"Pt. Maldonado","type":"station","lat":-12.6333,"long":-69.2,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Pt-Maldonado,Peru"},{"title":"Pucallpa","type":"station","lat":-8.4167,"long":-74.6,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Pucallpa,Peru"},{"title":"Tacna","type":"station","lat":-18.0667,"long":-70.3,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Tacna,Peru"},{"title":"Tarapoto","type":"station","lat":-6.45,"long":-76.3833,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Tarapoto,Peru"},{"title":"Trujillo","type":"station","lat":-8.1,"long":-79.0333,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Trujillo,Peru"},{"title":"Yurimaguas","type":"station","lat":-5.9,"long":-76.0833,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,Yurimaguas,Peru"},{"title":"Puno","type":"place","lat":-15.8678,"long":-70.0425,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,puno,Peru"},{"title":"Urubamba","type":"place","lat":-13.2949,"long":-72.1359,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,urubamba,Peru"},{"title":"Machupicchu","type":"place","lat":-13.1202,"long":-72.5341,"url":"http:\/\/www.weather-and-climate.com\/average-monthly-Rainfall-Temperature-Sunshine,machupicchu,Peru"}]; for (var i=0; i < markers.length; i++) { var marker = add_marker(map, markers[i], markers[i].type == 'station' ? icon_red : icon_yellow); bounds.extend(marker.getPosition()); } if (markers.length > 2) { map.fitBounds(bounds); } else { map.setCenter(bounds.getCenter()); map.setZoom(DEFAULT_ZOOM); } } function add_marker(map, data, icon) { var marker = new google.maps.Marker({ position: new google.maps.LatLng(data.lat, data.long), map: map, title: data.title, icon: icon }); google.maps.event.addListener(marker, 'click', function() { window.document.location = data.url } ); return marker; } Event.observe(window, 'load', init_gmap);