(Android/iOS/Browser) Accept `Promise` as return value of `TileOverlayOptions.getTile()`
MODIFY
README.md
README.md
-# Cordova GoogleMaps plugin for Android, iOS and Browser (version 2.4.5)
+# Cordova GoogleMaps plugin for Android, iOS and Browser (version 2.5.0-beta)
This plugin displays Google Maps in your application.
This plugin uses these libraries for each platforms:
---------------------------------------------------------------------------------------------------------
## Release Notes
+ - **v2.5.0**
+ - Add: (Android/iOS/Browser) `map.addFusionTableOverlay()`
+
+ - Add: (Android/iOS/Browser) Support `promise` for `TileOverlayOptions.getTile`. You must return new URL in 5 seconds.
+ ```js
+ var tileOverlay = map.addTileOverlay({
+ getTile: function(x, y, zoom) {
+ return new Promise(function(resolve, reject) {
+ somethingAsync(function(url) {
+ resolve(url);
+ });
+ });
+ }
+ });
+ ```
+
- **v2.4.6**
- Fix: (iOS) Only `src/ios/check_sdk_version.js` error.

MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.5.0-beta-20180925-1422" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+<plugin id="cordova-plugin-googlemaps" version="2.5.0-beta-20180925-1630" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>cordova-plugin-googlemaps</name>
<js-module name="Promise" src="www/Promise.js" />
<asset src="www/promise-7.0.4.min.js.map" target="promise-7.0.4.min.js.map" />

MODIFY
www/Map.js
www/Map.js
@@ -1205,7 +1205,17 @@ Map.prototype.addTileOverlay = function(tilelayerOptions, callback) {
if (!url || url === "(null)" || url === "undefined" || url === "null") {
url = "(null)";
}
+ if (url instanceof Promise) {
+ common.promiseTimeout(5000, url)
+ .then(function(finalUrl) {
+ cordova_exec(null, self.errorHandler, self.id + "-tileoverlay", 'onGetTileUrlFromJS', [hashCode, params.key, finalUrl]);
+ })
+ .catch(function() {
+ cordova_exec(null, self.errorHandler, self.id + "-tileoverlay", 'onGetTileUrlFromJS', [hashCode, params.key, "(null)"]);
+ });
+ } else {
cordova_exec(null, self.errorHandler, self.id + "-tileoverlay", 'onGetTileUrlFromJS', [hashCode, params.key, url]);
+ }
};
document.addEventListener(self.id + "-" + hashCode + "-tileoverlay", onNativeCallback);

(Android/iOS/Browser) Accept `Promise` as return value of `TileOverlayOptions.getTile()`