Google Maps - Zoom
Aumenta / diminuisce il valore di zoom
È possibile aumentare o diminuire il valore di zoom di una mappa modificando il valore di zoom attributo nelle opzioni della mappa.
Sintassi
Possiamo aumentare o diminuire il valore di zoom della mappa utilizzando l'opzione zoom. Di seguito è riportata la sintassi per modificare il valore di zoom della mappa corrente.
var mapOptions = {
zoom:required zoom value
};
Esempio: Zoom 6
Il codice seguente mostrerà la roadmap della città Vishakhapatnam con un valore di zoom di 6.
<!DOCTYPE html>
<html>
<head>
<script src = "https://maps.googleapis.com/maps/api/js"></script>
<script>
function loadMap() {
var mapOptions = {
center:new google.maps.LatLng(17.609993, 83.221436),
zoom:6,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("sample"),mapOptions);
}
</script>
</head>
<body onload = "loadMap()">
<div id = "sample" style = "width:587px; height:400px;"></div>
</body>
</html>
Produrrà il seguente output:
Esempio: Zoom 10
Il codice seguente mostrerà la roadmap della città Vishakhapatnam con un valore di zoom di 10.
<!DOCTYPE html>
<html>
<head>
<script src = "https://maps.googleapis.com/maps/api/js"></script>
<script>
function loadMap() {
var mapOptions = {
center:new google.maps.LatLng(17.609993, 83.221436),
zoom:10,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("sample"),mapOptions);
}
</script>
</head>
<body onload = "loadMap()">
<div id = "sample" style = "width:587px; height:400px;"></div>
</body>
</html>
Produrrà il seguente output: