开发者

How to find current zoom level in a Google Map?

开发者 https://www.devze.com 2023-03-13 20:59 出处:网络
How do I find the current zoo开发者_开发问答m level when loading or clicking a Google map?If you have a map object like this:

How do I find the current zoo开发者_开发问答m level when loading or clicking a Google map?


If you have a map object like this:

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

use

mapObject.getZoom();


Use this code:

float zoomlevel = mMap.getCameraPosition().zoom;


If you need to get zoom on change

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


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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消