Google Maps API - 慢速最大变焦服务 [英] Google Maps API - Slow Max Zoom Service

查看:100
本文介绍了Google Maps API - 慢速最大变焦服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Google Maps API的Max Zoom Service获取给定坐标的最大缩放级别。大部分时间很快,每个请求只需要大约150毫秒。然而,有几次该服务变得非常缓慢,大约20秒。

  maxZoomService = new google.maps。 MaxZoomService的(); 
maxZoomService.getMaxZoomAtLatLng(center,function(response){

//我的进程

});

您是否遇到类似问题?

解决方案

是的,我们遇到过同样的问题。
我们使用wkhtmltoimage生成地图图像,使用wkhtmltopdf将其包含到PDF文件中。
我们必须设置图像生成的最长时间。如果太短,则通常不会为了创建图像而下载所有的地图块。太长了,对用户来说有一个非常明显的延迟(我们的合作5秒似乎是最佳的)
我们想要确保使用MaxZoomService生成的卫星地图不会超过最大缩放级别,这就是当我们遇到问题时因为这是一个异步服务,理想情况下,我们等待服务在创建地图之前报告最大缩放级别,并因此触发正确的.map瓦片下载。

如果服务非常慢,为地图设置默认的后备缩放并不是真正的选择,因为在获取返回值时更新缩放级别从服务将在大多数情况下导致新的瓷砖重新加载,需要更多的延迟... ...

如果像我们你有兴趣在特定的,可重复的位置(例如从一个数据库),那么一个选项可能是提前缓存(存储)最大缩放级别,并定期检查更新的值。



在我们的特定情况下,唯一的其他选择是允许服务达到特定的时间(比如2秒),如果它没有响应,则会回退到默认缩放。



不理想,但可以处理服务的糟糕的头发日...


I am using Max Zoom Service of Google Maps API to get the maximum zoom level of a given coordinates. Most of the time it is fast and each request only takes around 150 ms. However, there have been a few occasions that the service became extremely slow, around 20 seconds.

maxZoomService = new google.maps.MaxZoomService();
maxZoomService.getMaxZoomAtLatLng(center, function(response) {

// my process

});

Have you experienced similar issue?

解决方案

Yes we have experienced the same problems. We're using wkhtmltoimage to generate map images for inclusion into PDF files using wkhtmltopdf. We have to set a maximum time in which the image is generated. If it's too short, then you often will not have all the map tiles downloaded in order to create the image. Too long and there's a really noticeable delay for users (with our comnection 5 seconds seems optimal) We wanted to make sure that generated satellite maps do not exceed the maximum zoom level using the MaxZoomService and that's when we ran into problems with the service.

As it is an asynchronous service, ideally we wait for the service to report the max zoom level BEFORE creating the map and therefore triggering the correct .map tile downloads.

Setting a default "fallback" zoom for the map in case the service is being really slow is not really an option as subsequently updating the zoom level when getting a return value from the service will in most cases cause new tiles to be reloaded, requiring more delay...

If like us you're interested in specific, repeatable locations (e.g. from a database) then one option might be to cache (store) the max zoom levels in advance and periodically check for updated values.

In our specific case the only other option would be to allow the service a specific amount of time (say 2 seconds) and if it does not respond then fall back to a default zoom.

Not ideal, but can handle the services' "Bad hair days"...

这篇关于Google Maps API - 慢速最大变焦服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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