How do I find the current zoom level when loading or clicking a Google map?
Asked
Active
Viewed 1.1e+01k times
98
-
11um, [`Map.getZoom()`](http://code.google.com/apis/maps/documentation/javascript/reference.html)? – Pekka Jun 17 '11 at 12:28
4 Answers
170
If you have a map object like this:
var mapObject = new google.maps.Map(document.getElementById("map"), _mapOptions);
use
mapObject.getZoom();

bert
- 7,566
- 3
- 31
- 47

Nicola Peluchetti
- 76,206
- 31
- 145
- 192
-
7
-
1
-
-
8If you are using google maps api2, then you have to do it like this: `map.getCameraPosition().zoom` – AlvaroSantisteban Jul 30 '14 at 14:42
-
1
20
Use this code:
float zoomlevel = mMap.getCameraPosition().zoom;

Ingo
- 5,239
- 1
- 30
- 24
-
While this code snippet may solve the question, [including an explanation](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – Rosário Pereira Fernandes Jan 22 '18 at 01:43
12
If you need to get zoom on change
google.maps.event.addListener(map, 'zoom_changed', function() {
var zoom = map.getZoom();
console.log(zoom);
});

Endrit Vitija
- 121
- 1
- 7
3
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;
}

Flavio Marques
- 79
- 1
- 4