JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
ahoj
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<div id="map-canvas"></div>
CSS
html, body, #map-canvas { xwidth: 100%; height: 100%; margin: 0; padding: 0; }
#map-canvas { border: solid red 1px; }
JavaScript
//alert(1);
//alert(typeof google.maps.LatLng);
var mapOptions = {
zoom: 6,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
//alert(2);
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
alert(map.getZoom())
map.fitBounds(new google.maps.LatLngBounds(new google.maps.LatLng(48.5,12.1), new google.maps.LatLng(51.1,18.9)));
//map.setZoom(2);
if (1)
google.maps.event.addListenerOnce(map,
//'idle',
'zoom_changed',
//'bounds_changed',
function() {
//alert('it definitely works');
alert('ahoj' + map.getZoom());
map.setZoom(2);
});