简体   繁体   English

单击动画放大到Google地图位置(自定义Google Maps控件)

[英]Animate zoom to google map location on click(custom google maps controls)

I want to have google map displaying whole planet(zoomed out maximally). 我想让Google地图显示整个星球(最大程度地缩小)。 Then, I would like to put overlay over map with button. 然后,我想用按钮在地图上放置叠加层。 When user click on button the overlay is removed and google map is automatically animating to the location i want. 当用户单击按钮时,覆盖层将被删除,谷歌地图会自动设置动画到我想要的位置。

So, I am not asking for complete solution, I just want you to tell me if it's possible to do that using google map js api, and if you can give me some direction, that would be awesome. 因此,我并不是要寻求完整的解决方案,我只是想告诉您是否可以使用google map js api来做到这一点,并且如果您能给我一些指导,那将很棒。 I have searched a lot but found nothing on this subject. 我进行了很多搜索,但未找到关于此主题的任何信息。

Thanks. 谢谢。

I've noticed, that if difference between current zoom level and new zoom level more that 2, google maps won't make smooth zooming. 我注意到,如果当前缩放级别和新缩放级别之间的差异大于2,则Google地图将无法平滑缩放。

You can take a look at same question: How to zoom in smoothly on a marker in Google Maps? 您可以看看相同的问题: 如何在Google Maps中平滑放大标记?

map.setCenter(new google.maps.LatLng(theLatitude, theLongitude));
map.setZoom(yourZoomLevel);

See also: change location to preset coordinates and zoom with click of a button 另请参阅: 将位置更改为预设坐标并单击按钮进行缩放

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM