谷歌地图的第二个电话不会显示正确大小的地图 [英] second call of google maps does not show the map in correct size

查看:104
本文介绍了谷歌地图的第二个电话不会显示正确大小的地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用gwt-maps-3.8.0我在gwt弹出窗口中显示路由。有一次调用但第二次调用不起作用。

我应该怎么做...一些建议刷新mapWidget?

解决方案



在文档中:
$ b


当div更改大小时,开发人员应在地图上触发此事件: google.maps.event.trigger map,'resize')


出现在GWT中执行此操作的方式是

  Event.trigger(mapWidget.getMap(),resize); 

目前,就API而言,地图的大小为零,所以它只是显示(0,0)处单个像素周围的瓦片缓冲区。触发 resize 事件会导致API从浏览器中获取正确的大小,因此正确的图块将被提取以供显示。


using gwt-maps-3.8.0 i display a route in a gwt popup. Works when called once but does not work on second call.

What should i do ... some advice to refresh the mapWidget?

解决方案

When you display the map, trigger its resize event.

From the documentation:

Developers should trigger this event on the map when the div changes size: google.maps.event.trigger(map, 'resize')

It appears the way to do this in GWT is

Event.trigger(mapWidget.getMap(), "resize");

At the moment, the map has zero size as far as the API is concerned, so it's just displaying the buffer of tiles around the single pixel at (0,0). Triggering the resize event causes the API to get the correct size from the browser so the right tiles are fetched for display.

这篇关于谷歌地图的第二个电话不会显示正确大小的地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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