最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Get zoom size on Google Map API - Stack Overflow

programmeradmin1浏览0评论

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.

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

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.

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

Share Improve this question asked Apr 29, 2013 at 5:52 MajAfyMajAfy 3,09712 gold badges50 silver badges83 bronze badges
Add a comment  | 

4 Answers 4

Reset to default 14

Easy. As per docs:

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

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

map.getZoom().

It's in the docs!

you can use zoom_changed event for this..

check this link

You have to keep a div that will show the map I am having ('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());
});
发布评论

评论列表(0)

  1. 暂无评论