K6t
K6t

Reputation: 1845

How to find current zoom level in a Google Map?

How do I find the current zoom level when loading or clicking a Google map?

Upvotes: 101

Views: 117312

Answers (4)

Endrit Vitija
Endrit Vitija

Reputation: 141

If you need to get zoom on change

google.maps.event.addListener(map, 'zoom_changed', function() {
    var zoom = map.getZoom();
    console.log(zoom);
});

Upvotes: 14

Flavio Marques
Flavio Marques

Reputation: 79

I got it using:

console.log(this.map.zoom);

I'm using agm-angular-google-maps

html:

<agm-map (mapReady)="onMapReady($event)">

TS:

onMapReady(map) {
 this.map = map;
}

Upvotes: 3

Ingo
Ingo

Reputation: 5381

Use this code:

float zoomlevel = mMap.getCameraPosition().zoom;

Upvotes: 21

Nicola Peluchetti
Nicola Peluchetti

Reputation: 76870

If you have a map object like this:

var mapObject = new google.maps.Map(document.getElementById("map"), _mapOptions);

use

mapObject.getZoom();

Upvotes: 172

Related Questions