second call of google maps does not show the map in correct size

前端 未结 3 675
离开以前
离开以前 2021-01-14 08:24

using gwt-maps-3.8.0 i display a route in a gwt popup. Works when called once but does not work on second call.

What should i do ... some advice to refresh the mapW

3条回答
  •  终归单人心
    2021-01-14 08:59

    When you display the map, trigger its resize event.

    From the documentation:

    Developers should trigger this event on the map when the div changes size: google.maps.event.trigger(map, 'resize')

    It appears the way to do this in GWT is

    Event.trigger(mapWidget.getMap(), "resize");
    

    At the moment, the map has zero size as far as the API is concerned, so it's just displaying the buffer of tiles around the single pixel at (0,0). Triggering the resize event causes the API to get the correct size from the browser so the right tiles are fetched for display.

提交回复
热议问题