How to find current zoom level in a Google Map?

Google Maps-Api-3Map

Google Maps-Api-3 Problem Overview


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

Google Maps-Api-3 Solutions


Solution 1 - Google Maps-Api-3

If you have a map object like this:

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

use

mapObject.getZoom();

Solution 2 - Google Maps-Api-3

Use this code:

float zoomlevel = mMap.getCameraPosition().zoom;

Solution 3 - Google Maps-Api-3

If you need to get zoom on change

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

Solution 4 - Google Maps-Api-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;
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionK6tView Question on Stackoverflow
Solution 1 - Google Maps-Api-3Nicola PeluchettiView Answer on Stackoverflow
Solution 2 - Google Maps-Api-3IngoView Answer on Stackoverflow
Solution 3 - Google Maps-Api-3Endrit VitijaView Answer on Stackoverflow
Solution 4 - Google Maps-Api-3Flavio MarquesView Answer on Stackoverflow