Created
July 29, 2012 10:49
-
-
Save jareware/3197529 to your computer and use it in GitHub Desktop.
Google Maps API async loading w/ require.js 2.0
This file contains 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 characters
// lib/google-maps-loader.js | |
define({ | |
load: function(name, require, load, config) { | |
var callback = 'maps_loader_' + new Date().getTime(); | |
window[callback] = function() { | |
load(window.google); | |
}; | |
require([ 'http://maps.googleapis.com/maps/api/js?key=' + name + '&sensor=false&callback=' + callback ]); | |
} | |
}); | |
// lib/google-maps.js | |
define([ 'lib/google-maps-loader!API_KEY_GOES_HERE' ], function(google) { | |
return google; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment