-
-
Save backflip/8613939 to your computer and use it in GitHub Desktop.
Revisions
-
backflip revised this gist
Jan 25, 2014 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ { "name": "load-google-maps", "version": "1.0.0", "main": ["./load-google-maps.js"], "author": "Glenn Baker & Gavin Foley", "dependencies": { "jquery": ">=1.5" }, "license": ["MIT", "GPL"], "keywords": ["Google Maps", "Async"] } -
GFoley83 revised this gist
Jul 13, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ $(elem).on("myevent", function() { $.when( loadGoogleMaps( 3, API_KEY, LANG, SENSOR ) ) .then(function() { // or .done(...) !!google.maps // true }); -
GFoley83 revised this gist
Jul 13, 2013 . 1 changed file with 6 additions and 90 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,90 +1,6 @@ $(elem).on("myevent", function() { $.when( loadGoogleMaps( 3, API_KEY, LANG ) ) .then(function() { // or .done(...) !!google.maps // true }); }); -
GFoley83 revised this gist
Jul 13, 2013 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,7 +36,7 @@ var loadGoogleMaps = (function ($) { // Default Parameters params = $.extend({ "sensor": sensor || "false" }, apiKey ? { "key": apiKey @@ -52,7 +52,7 @@ var loadGoogleMaps = (function ($) { } else if (window.google && window.google.load) { window.google.load("maps", version || 3, { "other_params": $.param(params), "callback": resolve }); //Last, try pure jQuery Ajax technique to load the Google Maps API in Async. } else { @@ -69,7 +69,7 @@ var loadGoogleMaps = (function ($) { setTimeout(function () { try { delete window[callbackName]; } catch (e) {} }, 20); }; -
GFoley83 revised this gist
Jul 13, 2013 . 1 changed file with 90 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,90 @@ /*! * JavaScript - loadGoogleMaps( version, apiKey, language, sensor ) * * - Load Google Maps API using jQuery Deferred. * Useful if you want to only load the Google Maps API on-demand. * - Requires jQuery 1.5 * * UPDATES by Gavin Foley * - Tidied JS & made it JSLint compliant * - Updated script request to Google Maps API to be protocol relative * - Added "sensor" parameter which defaults to false if not present * * Copyright (c) 2011 Glenn Baker * Dual licensed under the MIT and GPL licenses. */ /*globals window, google, jQuery*/ var loadGoogleMaps = (function ($) { "use strict"; var now = $.now(), promise; return function (version, apiKey, language, sensor) { if (promise) { return promise; } //Create a Deferred Object var deferred = $.Deferred(), //Declare a resolve function, pass google.maps for the done functions resolve = function () { deferred.resolve(window.google && window.google.maps ? window.google.maps : false); }, //global callback name callbackName = "loadGoogleMaps_" + (now++), // Default Parameters params = $.extend({ "sensor": sensor || "false" }, apiKey ? { "key": apiKey } : {}, language ? { "language": language } : {}); //If google.maps exists, then Google Maps API was probably loaded with the <script> tag if (window.google && window.google.maps) { resolve(); //If the google.load method exists, lets load the Google Maps API in Async. } else if (window.google && window.google.load) { window.google.load("maps", version || 3, { "other_params": $.param(params), "callback": resolve }); //Last, try pure jQuery Ajax technique to load the Google Maps API in Async. } else { //Ajax URL params params = $.extend(params, { 'callback': callbackName }); //Declare the global callback window[callbackName] = function () { resolve(); //Delete callback setTimeout(function () { try { delete window[callbackName]; } catch (e) {} }, 20); }; //Can't use the jXHR promise because 'script' doesn't support 'callback=?' $.ajax({ dataType: 'script', data: params, url: '//maps.googleapis.com/maps/api/js' }); } promise = deferred.promise(); return promise; }; })(jQuery); -
GFoley83 revised this gist
Jul 8, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ * - Requires jQuery 1.5 * * UPDATES by Gavin Foley * - Tidied JS & made it JSLint compliant * - Updated script request to Google Maps API to be protocol relative * - Added "sensor" parameter which defaults to false if not present * -
GFoley83 revised this gist
Jul 8, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ /*! * JavaScript - loadGoogleMaps( version, apiKey, language, sensor ) * * - Load Google Maps API using jQuery Deferred. * Useful if you want to only load the Google Maps API on-demand. -
GFoley83 revised this gist
Jul 8, 2013 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,11 @@ * - Load Google Maps API using jQuery Deferred. * Useful if you want to only load the Google Maps API on-demand. * - Requires jQuery 1.5 * * UPDATES by Gavin Foley * - Tidied JS & made it JSLint complient * - Updated script request to Google Maps API to be protocol relative * - Added "sensor" parameter which defaults to false if not present * * Copyright (c) 2011 Glenn Baker * Dual licensed under the MIT and GPL licenses. -
GFoley83 revised this gist
Jul 8, 2013 . 1 changed file with 73 additions and 74 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,78 +9,77 @@ * Dual licensed under the MIT and GPL licenses. */ /*globals window, google, jQuery*/ var loadGoogleMaps = (function ($) { "use strict"; var now = $.now(), promise; return function (version, apiKey, language, sensor) { if (promise) { return promise; } //Create a Deferred Object var deferred = $.Deferred(), //Declare a resolve function, pass google.maps for the done functions resolve = function () { deferred.resolve(window.google && window.google.maps ? window.google.maps : false); }, //global callback name callbackName = "loadGoogleMaps_" + (now++), // Default Parameters params = $.extend({ 'sensor': sensor ? sensor : "true" }, apiKey ? { "key": apiKey } : {}, language ? { "language": language } : {}); //If google.maps exists, then Google Maps API was probably loaded with the <script> tag if (window.google && window.google.maps) { resolve(); //If the google.load method exists, lets load the Google Maps API in Async. } else if (window.google && window.google.load) { window.google.load("maps", version || 3, { "other_params": $.param(params), "callback": resolve }); //Last, try pure jQuery Ajax technique to load the Google Maps API in Async. } else { //Ajax URL params params = $.extend(params, { 'callback': callbackName }); //Declare the global callback window[callbackName] = function () { resolve(); //Delete callback setTimeout(function () { try { delete window[callbackName]; } catch (e) { } }, 20); }; //Can't use the jXHR promise because 'script' doesn't support 'callback=?' $.ajax({ dataType: 'script', data: params, url: '//maps.googleapis.com/maps/api/js' }); } promise = deferred.promise(); return promise; }; })(jQuery); -
gbakernet renamed this gist
Feb 8, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
gbakernet revised this gist
Feb 8, 2012 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ $(elem).on("myevent", function() { $.when( loadGoogleMaps( 3, API_KEY, LANG ) ) .then(function() { !!google.maps // true }); }); // OR $(elem).on("myevent", function() { loadGoogleMaps( 3, API_KEY, LANG ) .done(function() { !!google.maps // true }); }); -
gbakernet revised this gist
Jan 9, 2012 . 1 changed file with 11 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ /*! * JavaScript - loadGoogleMaps( version, apiKey, language ) * * - Load Google Maps API using jQuery Deferred. * Useful if you want to only load the Google Maps API on-demand. @@ -15,7 +15,7 @@ var loadGoogleMaps = (function($) { promise; return function( version, apiKey, language ) { if( promise ) { return promise; } @@ -30,8 +30,12 @@ var loadGoogleMaps = (function($) { //global callback name callbackName = "loadGoogleMaps_" + ( now++ ), // Default Parameters params = $.extend( {'sensor': false} , apiKey ? {"key": apiKey} : {} , language ? {"language": language} : {} );; //If google.maps exists, then Google Maps API was probably loaded with the <script> tag if( window.google && google.maps ) { @@ -41,17 +45,16 @@ var loadGoogleMaps = (function($) { //If the google.load method exists, lets load the Google Maps API in Async. } else if ( window.google && google.load ) { google.load("maps", version || 3, {"other_params": $.param(params) , "callback" : resolve}); //Last, try pure jQuery Ajax technique to load the Google Maps API in Async. } else { //Ajax URL params params = $.extend( params, { 'v': version || 3, 'callback': callbackName }); //Declare the global callback window[callbackName] = function( ) { -
gbakernet revised this gist
Sep 5, 2011 . 1 changed file with 9 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,13 +8,17 @@ * Copyright (c) 2011 Glenn Baker * Dual licensed under the MIT and GPL licenses. */ /*globals window, google, jQuery*/ var loadGoogleMaps = (function($) { var now = $.now(), promise; return function( version, apiKey ) { if( promise ) { return promise; } //Create a Deferred Object var deferred = $.Deferred(), @@ -71,7 +75,9 @@ var loadGoogleMaps = (function($) { } promise = deferred.promise(); return promise; }; }(jQuery)); -
gbakernet revised this gist
Feb 18, 2011 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ var loadGoogleMaps = (function($) { var now = $.now(); return function( version, apiKey ) { @@ -20,7 +20,7 @@ var loadGoogleMaps = (function($) { //Declare a resolve function, pass google.maps for the done functions resolve = function () { deferred.resolve( window.google && google.maps ? google.maps : false ); }, //global callback name @@ -30,12 +30,12 @@ var loadGoogleMaps = (function($) { params; //If google.maps exists, then Google Maps API was probably loaded with the <script> tag if( window.google && google.maps ) { resolve(); //If the google.load method exists, lets load the Google Maps API in Async. } else if ( window.google && google.load ) { google.load("maps", version || 3, {"other_params": "sensor=false", "callback" : resolve}); @@ -47,7 +47,7 @@ var loadGoogleMaps = (function($) { 'v': version || 3, 'sensor': false, 'callback': callbackName }, apiKey ? {"key": apiKey} : {} ); //Declare the global callback window[callbackName] = function( ) { -
gbakernet created this gist
Feb 15, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,77 @@ /*! * JavaScript - loadGoogleMaps( version, apiKey ) - 16/02/2011 * * - Load Google Maps API using jQuery Deferred. * Useful if you want to only load the Google Maps API on-demand. * - Requires jQuery 1.5 * * Copyright (c) 2011 Glenn Baker * Dual licensed under the MIT and GPL licenses. */ var loadGoogleMaps = (function($) { var now = jQuery.now(); return function( version, apiKey ) { //Create a Deferred Object var deferred = $.Deferred(), //Declare a resolve function, pass google.maps for the done functions resolve = function () { deferred.resolve( google && google.maps ? google.maps : false ); }, //global callback name callbackName = "loadGoogleMaps_" + ( now++ ), //Ajax URL params params; //If google.maps exists, then Google Maps API was probably loaded with the <script> tag if( google && google.maps ) { resolve(); //If the google.load method exists, lets load the Google Maps API in Async. } else if ( google && google.load ) { google.load("maps", version || 3, {"other_params": "sensor=false", "callback" : resolve}); //Last, try pure jQuery Ajax technique to load the Google Maps API in Async. } else { //Ajax URL params params = $.extend({ 'v': version || 3, 'sensor': false, 'callback': callbackName }, apiKey ? {"key": apiKey} : {} ) //Declare the global callback window[callbackName] = function( ) { resolve(); //Delete callback setTimeout(function() { try{ delete window[callbackName]; } catch( e ) {} }, 20); }; //Can't use the jXHR promise because 'script' doesn't support 'callback=?' $.ajax({ dataType: 'script', data: params, url: 'http://maps.google.com/maps/api/js' }); } return deferred.promise(); }; }(jQuery));