Fire ResizeEvent in GWT (Google Web Toolkit)

On my site, I have several Google Maps (v3) that you can select using TabPanel (one per tab), but there is a problem switching tabs. When you select a tab, it does not “wake up” on the map. To fix this, I just need to use ResizeEvent.fire ( source , Window.getClientWidth (), Window.getClientHight ()); this activates the resize listener on the map and wakes him up. My problem is that I can’t get a pointer to the registered resize handlers for the browser window (it is protected by the package in com.google.gwt.user.client.Window.handlers), so I don’t know what to use as the source. If anyone has an answer to my decision or other possible solution, we will be very grateful.

Thanks Tom

+4
source share
3 answers

Thanks for your answer, but I realized that these three lines:
HasLatLng center = mapWidget.getMap().getCenter();
Event.trigger(mapWidget.getMap(), "resize");
mapWidget.getMap().setCenter(center);
Show the trick. This is basically what happens when the card loads initially. In the onLoad () method for MapWidget, it calls super.onLoad (), then executes these three lines, which “wake up” on the map and save the center point.

0
source

I'm not sure that using resize is the best way to do this (I haven't inserted a map before), but you might consider using TabLayoutPanel instead of TabPanel and the call bar. onResize () instead of triggering a resize event. Note that you will need to use * LayoutPanel (or something that implements ProvidesResize ), right down to the root of the document, and your page should display in standard mode.

0
source

If you use GWT-Maps-V3-Api , there is a triggerResize() function in the MapWidget class that does the trick.

0
source

Source: https://habr.com/ru/post/1345491/


All Articles