// PLUGIN: Google Maps
var googleCallback;
(function (Popcorn) {
- if ( typeof google !== 'undefined' && google.maps && typeof google.maps.Geocoder !== 'undefined' &&
- typeof google.maps.LatLng !== 'undefined' ) {
- geocoder = new google.maps.Geocoder();
- _mapLoaded = true;
+ var newdiv,
+ i = 1,
+ _mapFired = false,
+ _mapLoaded = false,
+ geocoder,
+ loadMaps;
+ //google api callback
+ googleCallback = function( data ) {
+ // ensure all of the maps functions needed are loaded
+ // before setting _maploaded to true
++ if ( typeof google !== "undefined" && google.maps && google.maps.Geocoder && google.maps.LatLng ) {
++ geocoder = new google.maps.Geocoder();
++ _mapLoaded = true;
+ } else {
+ setTimeout( function() {
+ googleCallback( data );
+ }, 1);
+ }
+ };
+ // function that loads the google api
+ loadMaps = function () {
+ // for some reason the Google Map API adds content to the body
+ if ( document.body ) {
+ _mapFired = true;
+ Popcorn.getScript( "http://maps.google.com/maps/api/js?sensor=false&callback=googleCallback" );
+ } else {
+ setTimeout( function() {
+ loadMaps( );
+ }, 1);
+ }
+ };
+ // if this is the firest time running the plugins
+ // call the function that gets the sctipt
+ if ( !_mapFired ) {
+ loadMaps();
+ }
/**
* googlemap popcorn plug-in