放大标记google.maps [英] Zoom in to marker google.maps
问题描述
我无法正确缩放到标记。
我试图将视图切换到指定的标记,但无法工作。
我试过了
map.setCenter(location);
map.setZoom(20);
和
map.fitBounds(new google.maps.latLngBounds(location,location));
但是在第一种情况下,我只是在没有注册中心变化的情况下进行放大,而在第二种情况我在一个很大的区域得到这个概述,根本没有放大。
也许这个问题可以通过设置从setcenter到setzoom的timout来解决,但这是一个丑陋的黑客给我,所以一个更漂亮的解决方案将是首选。
你们是如何做到这一点的?
另外 - 如果infowindow可以在不改变内容的情况下显示,那真的是一个加号,但最重要的是在正确的位置放大标记,关闭。
$ p
解决方案竟然是
map.setZoom(17);
map.panTo(curmarker.position);
I can't zoom to a marker properly.
I'm trying to switch the view to a specified marker, but can't ge tit to work.
I've tried
map.setCenter(location);
map.setZoom(20);
and
map.fitBounds(new google.maps.latLngBounds(location,location));
but in the first case, I simply get zoomed in without the center change being registered, and in the second case I get this overview over a huge area, not zoomed in at all.
Perhaps this issue could be solved by setting a timout from setcenter to setzoom, but that's an ugly hack to me, so a prettier solution would be preferred.
How do you guys do this?
Also - if the infowindow could be displayed without changing content, that would really be a plus to, but the most important thing is to zoom into the marker at the right spot, close up.
thank you very much.
The solution turned out to be
map.setZoom(17);
map.panTo(curmarker.position);
这篇关于放大标记google.maps的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!