java - 如何在 Google map 上触发 map 事件 < v3

标签 java google-maps gwt

我在使用加载多个 Google map 的应用时遇到问题。第二张 map 有一个著名的问题,即显示效果不佳,因为似乎未正确找到 div 尺寸。我已经检查了建议的解决方案herehere 。所提出的解决方案都不适合我,因为我现在无法切换到 v3,我稍后会这样做,但现在无法这样做。

因此,如何在 google map API < v3 上触发调整大小事件?我已经尝试过这个:

HasLatLng center = mapWidget.getMap().getCenter();
Event.trigger(mapWidget.getMap(), "resize");
mapWidget.getMap().setCenter(center);

但是我的 MapWidget 类没有 getMap() 方法,此外我没有允许传递 MapWidget 和 String 作为参数的 Event 类。

最后,我也尝试过这个建议 here :

private final native void resizeMap(GoogleMap map) /*-{
    $wnd.google.maps.event.trigger(map, 'resize');
}-*/;

但这也不起作用...有什么线索吗?

谢谢! 亚历克斯

最佳答案

我不熟悉 GWT,但似乎 mapWidget 已经是指向 MapWidget 实例的指针。

也许checkResizeAndCenter()就是您正在寻找的。至少描述听起来很有希望:

Notifies the map of a change in the size of its container and moves to the center of the map. Call this method after the size of the container DOM object has changed, so that the map can adjust itself to fit the new size.

mapWidget.checkResizeAndCenter();

关于java - 如何在 Google map 上触发 map 事件 < v3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18805088/

相关文章:

java - 使用 Apache-tomcat 保护应用程序

search - Google map 搜索栏在 GWT 中调整大小

android - 如何使用 Cluster Manager 更改 Google map 上标记的可见性? (安卓)

GWT DatePicker 默认为中午

grails - 在 gwt 中使用 config.groovy 来获取用户偏好

java - 动态更改 side_nav_bar.xml 形状颜色的颜色

java - 基于Spring注解的AOP拦截父类中实现的方法

java - 当我在java代码中指定它是UTF-8时,为什么文本文件编码仍然是ANSI

ios - 如何保存 GMSCameraPosition?

Android 谷歌地图 API : How to get minimum and maximum coordinate can visible on map