Fix: (Android/iOS) can't load image files on addTileOverlay with ionic3
MODIFY
README.md
README.md
- Fix: Can not install to Cordova 9.0 project
- Fix: (Android) `ConcurrentModificationException` error at `onStop`
- Fix: (Android) Polygon becomes visible when you run `setPoints()` to invisible polygon
+ - Fix: (Android/iOS) TileOverlay does not work when your app runs on `file:` protocol with ionic.
- Update: (iOS) Specify the Google Maps SDK version as `~> 3.0.2`
- **v2.5.3**

MODIFY
package.json
package.json
{
"name": "cordova-plugin-googlemaps",
- "version": "2.5.4-beta-20190403-2250",
+ "version": "2.5.4-beta-20190416-1514",
"description": "Google Maps native SDK for Android and iOS, and Google Maps JavaScript API v3 for browser.",
"cordova": {
"id": "cordova-plugin-googlemaps",

MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.5.4-beta-20190415-0958" 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.4-beta-20190416-1514" 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
src/android/plugin/google/maps/AsyncLoadImage.java
src/android/plugin/google/maps/AsyncLoadImage.java
@@ -124,7 +124,11 @@ public class AsyncLoadImage extends AsyncTask<Void, Void, AsyncLoadImage.AsyncLo
mOptions.url = PluginUtil.getAbsolutePathFromCDVFilePath(resourceApi, mOptions.url);
}
- this.currentPageUrl = webView.getUrl();
+ String currentPage = webView.getUrl();
+ currentPage = currentPage.replaceAll("#.*$", "");
+ currentPage = currentPage.replaceAll("\\?.*$", "");
+ currentPage = currentPage.replaceAll("[^\\/]*$", "");
+ this.currentPageUrl = currentPage;
//Log.d(TAG, "-->currentPageUrl = " + this.currentPageUrl);

MODIFY
src/android/plugin/google/maps/PluginTileProvider.java
src/android/plugin/google/maps/PluginTileProvider.java
@@ -14,6 +14,7 @@ import android.os.Looper;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
+import android.util.Log;
import com.google.android.gms.maps.model.Tile;
import com.google.android.gms.maps.model.TileProvider;
@@ -296,6 +297,8 @@ public class PluginTileProvider implements TileProvider {
if (urlStr.startsWith("./") || urlStr.startsWith("../")) {
urlStr = urlStr.replace("././", "./");
String currentPage = webPageUrl;
+ currentPage = currentPage.replaceAll("#.*$", "");
+ currentPage = currentPage.replaceAll("\\?.*$", "");
currentPage = currentPage.replaceAll("[^\\/]*$", "");
urlStr = currentPage + "/" + urlStr;
}

MODIFY
src/ios/GoogleMaps/PluginTileProvider.m
src/ios/GoogleMaps/PluginTileProvider.m
@@ -152,7 +152,22 @@ NSDictionary *debugAttributes;
//-------------------------------------------------------
NSString *currentURL = [NSString stringWithString:self.webPageUrl];
currentURL = [currentURL stringByDeletingLastPathComponent];
+ currentURL = [currentURL stringByReplacingOccurrencesOfString:@"http:/localhost" withString:@"http://localhost"];
+ currentURL = [currentURL regReplace:@"\\#.*$" replaceTxt:@"" options:NSRegularExpressionCaseInsensitive];
+ currentURL = [currentURL regReplace:@"\\?.*$" replaceTxt:@"" options:NSRegularExpressionCaseInsensitive];
+ currentURL = [currentURL regReplace:@"[^\\/]*$" replaceTxt:@"" options:NSRegularExpressionCaseInsensitive];
+
currentURL = [currentURL stringByReplacingOccurrencesOfString:@"file:" withString:@""];
+
+ urlStr = [NSString stringWithFormat:@"%@%@", currentURL, urlStr];
+ NSRange range = [currentURL rangeOfString:@"http"];
+ if (range.location == 0) {
+ //-------------------------
+ // http:// or https://
+ //-------------------------
+ [self downloadImageWithX:x y:y zoom:zoom url:[NSURL URLWithString:urlStr] receiver:receiver];
+ return;
+ }
currentURL = [currentURL stringByReplacingOccurrencesOfString:@"//" withString:@"/"];
urlStr = [NSString stringWithFormat:@"file://%@/%@", currentURL, urlStr];
} else {

Fix: (Android/iOS) can't load image files on addTileOverlay with ionic3
https://github.com/ionic-team/ionic-native-google-maps/issues/190