fitBounds() shows whole earth (if map is first hidden and then shown)

前端 未结 5 1828
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-15 06:43

I have a bunch or markers, and I want to show only the area containing them. I found a long list of similar questions (see at the bottom of the post for some), but none of the s

5条回答
  •  花落未央
    2021-02-15 07:43

    Modify to your needs

    map.fitBounds(bounds);
    
    var listener = google.maps.event.addListener(map, "idle", function() { 
      if (map.getZoom() > 16) map.setZoom(16); 
      google.maps.event.removeListener(listener); 
    });
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题