Instead of putting the entire code of an external API in a javascript web resource and later referring it to call one of it’s method to perform some action, we can also hit the API URL directly and refer it’s methods. It can save us from adding one extra web resource for API code only. Below is the code to achieve this:
LoadApi: function () { $ = parent.$; // replace url with the API URL var url = "https://maps.googleapis.com/maps/api/js?key={apikey}&libraries=places"; $.when( $.getScript(url), $.Deferred(function (deferred) { $(deferred.resolve); }) ).done(function () { // Call method from API code and perform your actions //Here we have called load method as below: parent.google.load("maps", "3", { other_params: "libraries=places&sensor=false", "callback": "yourmethod"}); }); }
Hope it helps.