GMap in iframe gets off-center

Posted by Daj pan spokój on Stack Overflow See other posts from Stack Overflow or by Daj pan spokój
Published on 2010-06-18T07:55:47Z Indexed on 2010/06/18 8:43 UTC
Read the original article Hit count: 271

I have a Google Map (API 2) that used to work fine as a standalone page.

However, when I load the map page within an iframe (with Thickbox), the map gets off-center:
normally it's centered over Germany and in the iframe it centers on Iran, instead.

How to make the map center correctly?


My guesses:

The problem can result from the iframe loading time. I guess, that the script calculates window size basing on the iframe size when it's still loading. It's strange since I load the map when the document is ready.

$(document).ready(function() {
  setupSearchForm();
  setupMap();
  setupResults();
});

For instance, when I refresh the already loaded iframe the center comes back to Germany. A sample of code loading the map

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about iframe