From: Anna Sobiepanek Date: Mon, 28 Mar 2011 19:33:37 +0000 (-0400) Subject: Merge branch 't371' into 0.5 X-Git-Tag: v0.5~38^2~1 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=78f10ff3aade1e5650c7895701e5f3110961efaf;p=popcorn-js.git Merge branch 't371' into 0.5 --- 78f10ff3aade1e5650c7895701e5f3110961efaf diff --cc plugins/googlemap/popcorn.googlemap.js index 1a45eaf,11ae0c6..92dbc38 --- a/plugins/googlemap/popcorn.googlemap.js +++ b/plugins/googlemap/popcorn.googlemap.js @@@ -1,6 -1,43 +1,42 @@@ // PLUGIN: Google Maps var googleCallback; (function (Popcorn) { + 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 && typeof google.maps.Geocoder !== 'undefined' && - typeof google.maps.LatLng !== 'undefined' ) { - geocoder = new google.maps.Geocoder(); - _mapLoaded = 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