Viralk
Viralk

Reputation: 2389

Google Map is not displaying properly in javascript popup

I'm using Google map API to display map in simple javascript popup. While popup opens it will display as below: Map Preview in Javascript Popup http://122.170.97.189:81/gmap/preview.png I tried auto refresh div using Jquery for map div like: $('#map').fadeOut('slow').load().fadeIn("fast"); It refresh the map div but still the problem is not solved. If I press F12 in chrome and firefox the map is displaying correctly.

Upvotes: 2

Views: 1713

Answers (1)

Konrad Dzwinel
Konrad Dzwinel

Reputation: 37923

Call the google maps code to render the map after the popup is fully loaded. You should call google.maps.Map() inside $(document).ready() or after some timeout (setTimeout()).

When map object is created it tries to figure out how big the canvas is and if popup is not fully loaded yet it may get wrong values.

Upvotes: 4

Related Questions