Get google maps object of map in iframe
I want to include a Google Maps powered application from an external page (www.marinetraffic.com) that already add开发者_如何学JAVAs its own markers (Ships). I integrate this map using an iframe (this is the way recommended by the map provider).
However I want to be able to jump to certain markers (put on the map by marinetraffic.com). How do I get the corresponding Google Maps object with jQuery?
I see two problems here:
- Get into the iframe DOM (using .content()? but how?)
- Get the instance of the Google Maps object to add markers, jump to markers, zoom etc...
Any hints are greatly appreciated!
Thanks!
Felix
If the iframe is from another domain then you'd get same origin policy exceptions, because that is considered cross site scripting and it is blocked by the browser.
Otherwise you can access the iframe and use selectors in the following way:
$('#selector', frames['frame_name'].document).func_name();
精彩评论