How to update the google map if the map canvas of it changed its dimenstions?

前端 未结 2 1781
Happy的楠姐
Happy的楠姐 2021-01-15 09:12

I have a google map inside of a div which gets changed, its parent div can get an additional class which changes its dimensions. This changes causes the google map not to ge

相关标签:
2条回答
  • 2021-01-15 09:44

    While re-sizing the existing map would be more elegant, as a workaround you can empty the container div before re-creating the map, e.g. while (div.firstChild) div.removeChild(div.firstChild) or $(div).empty().

    0 讨论(0)
  • 2021-01-15 10:06

    Check the google.maps.Map class reference, I think you're looking for the resize event:

    Developers should trigger this event on the map when the div changes size:

    google.maps.event.trigger(map, 'resize')
    
    0 讨论(0)
提交回复
热议问题