gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 14:07:18 25 4
gpt4 key购买 nike

我在使用加载多个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com