放大标记google.maps [英] Zoom in to marker google.maps

查看:84
本文介绍了放大标记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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆