作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在使用加载多个 Google map 的应用时遇到问题。第二张 map 有一个著名的问题,即显示效果不佳,因为似乎未正确找到 div 尺寸。我已经检查了建议的解决方案here和 here 。所提出的解决方案都不适合我,因为我现在无法切换到 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/
我是一名优秀的程序员,十分优秀!