在我的网站上,我有一些Google Maps(v3),您可以通过TabPanel(每个选项卡一个)进行选择,但在切换选项卡时出现问题。当您选择标签时,它不会唤醒地图。要解决这个问题,我只需要使用ResizeEvent.fire( source ,Window.getClientWidth(),Window.getClientHight());这将在地图上激活调整大小的监听器并唤醒。我的问题是,我不能指向浏览器窗口的注册的resize处理程序(它是com.google.gwt.user.client.Window.handlers中的包保护),因此我不知道该用作我的源。如果有人对我的解决方案或另一种可能的解决方案有答案,那将是非常感谢。
On my site I have a number of Google Maps (v3) that you can select via a TabPanel (one per tab) but there is a problem when you switch tabs. When you select the tab it does not "wake up" the map. To fix this I simply need to use ResizeEvent.fire(source, Window.getClientWidth(), Window.getClientHight()); this will active the resize listener on the map and "wake it up." My problem is that I cant get a pointer to the registered resize handlers for the browser window (it is package protected in com.google.gwt.user.client.Window.handlers) therefore I don't know what to use as my source. If anyone has the answer to my solution or another possible solution it would be greatly appreciated.
谢谢,Tom
推荐答案感谢您的回复,但我发现这三行: HasLatLng center = mapWidget.getMap()。getCenter(); Event.trigger(mapWidget.getMap(),resize); mapWidget.getMap()。setCenter(center); 做窍门。这基本上是当地图最初加载时会发生什么。在MapWidget的onLoad()方法中,调用super.onLoad()然后执行这三行唤醒地图并保留中心点。
Thanks for your reply but I figured out that these three lines: HasLatLng center = mapWidget.getMap().getCenter(); Event.trigger(mapWidget.getMap(), "resize"); mapWidget.getMap().setCenter(center); do the trick. This is basically what happens when the map loads initially. In the onLoad() method for MapWidget it makes a call to super.onLoad() then executes these three lines which "wakes up" the map and preserves the center point.
更多推荐
GWT中的Fire ResizeEvent(Google Web Toolkit)
发布评论