javascript 在 Google Map API 上获取缩放大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16272000/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 04:00:19  来源:igfitidea点击:

Get zoom size on Google Map API

javascriptgoogle-mapsgoogle-maps-api-3

提问by MajAfy

How can I get the zoom size in google map after changing by mouse wheel or zoom bar ?

通过鼠标滚轮或缩放条更改后,如何在谷歌地图中获取缩放大小?

I use Google Map API 3 with JavaScript.

我使用带有 JavaScript 的 Google Map API 3。

I want to show in console.log()with every change.

我想展示console.log()每一个变化。

回答by Jordan Arseno

Easy. As per docs:

简单。根据文档

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

Here's a great utilitythat shows all the events as they fire.

这是一个很棒的实用程序,可以在事件触发时显示所有事件。

回答by Cianan Sims

map.getZoom().

map.getZoom().

It's in the docs!

在里面 the docs!

回答by Cianan Sims

you can use zoom_changed event for this..

您可以为此使用 zoom_changed 事件..

check this link

检查此链接

回答by Ankur Verma

You have to keep a div that will show the map I am having ('map_canvas').

你必须保留一个 div 来显示我拥有的地图('map_canvas')。

var map = new google.maps.Map(document.getElementById('map_canvas'), {
        disableDefaultUI : true,
        zoom : 12,
        center : new google.maps.LatLng(17.1312321,78.23123123),
        mapTypeId : google.maps.MapTypeId.ROADMAP
    });



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