Skip to content

Instantly share code, notes, and snippets.

@hamishcampbell
Created November 23, 2012 01:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamishcampbell/4133562 to your computer and use it in GitHub Desktop.
Save hamishcampbell/4133562 to your computer and use it in GitHub Desktop.
Dojo 1.8 / AMD Style Gmaps Loader
/**
* Dojo AMD Google Maps Loader Plugin
*/
define([
"dojo/_base/kernel",
"dojo/topic"
], function(kernel, topic) {
var w = kernel.global;
w._googleApiLoadCallback = function() {
w.GMAPS_API_AVAILABLE = true;
topic.publish("/google/maps/apiloaded", w.google.maps);
};
return {
load: function(param, req, loadCallback) {
if(w.GMAPS_API_AVAILABLE) {
return w.google.maps;
} else {
topic.subscribe("/google/maps/apiloaded", loadCallback);
require([FULL_PATH_TO_GMAPS_API], function() { /* Do nothing */ });
}
}
};
});
@eivindeizer
Copy link

Can you give me a sample of how to use it? (from a beginner point of view)

@ca0v
Copy link

ca0v commented Nov 13, 2013

Here's a working example of a loader based on this one:
https://gist.github.com/ca0v/7450696

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment