避免“抱歉,我们在这里没有图像"与谷歌地图 [英] Avoiding "Sorry, we have no imagery here" with Google Maps

查看:149
本文介绍了避免“抱歉,我们在这里没有图像"与谷歌地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写Google Maps应用程序,在大多数情况下都可以正常工作.但是,如果我要求在彼此非常接近的2个点之间行走(例如2座彼此相邻的建筑物),那么地图会放大得如此近,以至于混合图像变成显示为抱歉,我们没有图像的图块"在这里."

I'm writing a Google Maps application, for the most part it works fine. But if I request walking directions between 2 points that are very close to each other (like 2 buildings that are next door to 1 another), the map zooms in so close that the hybrid images turns to tiles reading "Sorry, we have no imagery here."

从我代码中的调试说明来看,似乎直到更新了DirectionsRenderer的函数运行后才设置地图的缩放级别(添加map.getZoom()调用向我显示了地图的zoom属性我要求的上一轮指示.

From debugging notes in my code, it appears that the zoom level of the map isn't being set until after the function that updates the DirectionsRenderer runs (adding a map.getZoom() call shows me the map's zoom property for the previous round of directions I requested.

因此,MazZoomService也不是对我有任何帮助.

Because of this, MazZoomService isn't really doing me much good either. Is there a way to detect what the zoom level of the map will be when processing directions so I can zoom the image back out to something that doesn't show an error message?

推荐答案

在地图的"zoom_changed"事件中使用MaxZoomService.如果当前缩放级别大于最大值,请map.setZoom(max).

Use the MaxZoomService inside of the map's "zoom_changed" event. If the current zoom level is greater than the max, map.setZoom(max).

如果您只想从DirectionsRenderer更新的结果中启用此行为,则需要设置一个标志并可能设置一个计时器(DirectionsRenderer并不总是更改地图缩放级别).

If you wish to only enable this behavior from the results of a DirectionsRenderer update, you'll need to set a flag and possibly a timer (DirectionsRenderer doesn't always change the map zoom level).

这篇关于避免“抱歉,我们在这里没有图像"与谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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