Created
November 23, 2012 01:20
-
-
Save hamishcampbell/4133562 to your computer and use it in GitHub Desktop.
Dojo 1.8 / AMD Style Gmaps Loader
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 characters
/** | |
* 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 */ }); | |
} | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you give me a sample of how to use it? (from a beginner point of view)