Google Maps API Map Resize


	
var myLatlng = new google.maps.LatLng(45.5269, -34.9592); var myOptions = { zoom: 2, mapTypeControl: false, zoomControl: true, streetViewControl: false, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions ); map.setCenter(myLatlng); var actions = {'resizeuno': resizeuno, 'reset': reset}; for (var act in actions) { google.maps.event.addDomListener(document.getElementById(act),'click', actions[act]); } function resizeuno() { var southwest = new google.maps.LatLng(47.398, -106.639); var northeast = new google.maps.LatLng(48.153, -105.071); var bounds = new google.maps.LatLngBounds(southwest, northeast); map.fitBounds(bounds); } function reset() { map.setCenter(myLatlng); map.setZoom(2); } } $(document).ready(function() { $('#resizeuno').click(function() { $('#map_canvas').css({'width':'300','height':'400'}); google.maps.event.trigger(map, 'resize'); }); $('#reset').click(function() { $('#map_canvas').css({'width':'855','height':'550'}); google.maps.event.trigger(map, 'resize'); }); });
Created by