Skip to content

Commit

Permalink
FIX - mapsplugin#2886 - Custom markers not working for cordova-androi…
Browse files Browse the repository at this point in the history
…d 10+

* Add checked for https scheme
  • Loading branch information
ebhsgit authored and lempere committed Feb 8, 2022
1 parent 60f833e commit ff33131
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/android/plugin/google/maps/AsyncLoadImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ protected void onPreExecute() {
}

String currentPage = webView.getUrl();
if (currentPage == null) {
// Maybe someone close the map page.
this.cancel(true);
return;
}
currentPage = currentPage.replaceAll("#.*$", "");
currentPage = currentPage.replaceAll("\\?.*$", "");
currentPage = currentPage.replaceAll("[^\\/]*$", "");
Expand Down Expand Up @@ -185,16 +190,20 @@ protected AsyncLoadImageResult doInBackground(Void... params) {
return result;
}

//Log.d(TAG, "--> iconUrl = " + iconUrl);
// Log.d(TAG, String.format("---->iconURL = %s", iconUrl));
//--------------------------------
// Load image from local path
//--------------------------------
if (!iconUrl.startsWith("data:image")) {

if (currentPageUrl.startsWith("http://localhost") ||
currentPageUrl.startsWith("http://127.0.0.1")) {
if (iconUrl.startsWith("http://localhost") ||
iconUrl.startsWith("https://localhost") ||
iconUrl.startsWith("http://127.0.0.1") ||
iconUrl.startsWith("https://127.0.0.1")
) {
// Log.d(TAG, String.format("---->(201)iconURL = %s", iconUrl));
if (iconUrl.contains("://")) {
iconUrl = iconUrl.replaceAll("http://.+?/", "file:///android_asset/www/");
iconUrl = iconUrl.replaceAll("https?://.+?/", "file:///android_asset/www/");
} else {
// Avoid WebViewLocalServer (because can not make a connection for some reason)
iconUrl = "file:///android_asset/www/".concat(iconUrl);
Expand Down

0 comments on commit ff33131

Please sign in to comment.