Bug fix: Can not load image with file:// protocol (Issue
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.0.0-beta3-20170825-1109" 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.0.0-beta3-20170825-1220" 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="BaseClass" src="www/BaseClass.js">
<runs />

MODIFY
src/android/plugin/google/maps/AsyncLoadImage.java
src/android/plugin/google/maps/AsyncLoadImage.java
@@ -21,6 +21,7 @@ import org.apache.cordova.CordovaWebView;
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
@@ -183,7 +184,7 @@ public class AsyncLoadImage extends AsyncTask<Void, Void, AsyncLoadImage.AsyncLo
return result;
}
- //Log.d(TAG, "--> iconUrl = " + iconUrl);
+ Log.d(TAG, "--> iconUrl = " + iconUrl);
//--------------------------------
// Load image from local path
//--------------------------------
@@ -372,17 +373,22 @@ public class AsyncLoadImage extends AsyncTask<Void, Void, AsyncLoadImage.AsyncLo
} else {
- //Log.d(TAG, "--> iconUrl = " + iconUrl);
+ Log.d(TAG, "--> iconUrl = " + iconUrl);
if (iconUrl.indexOf("data:image/") == 0 && iconUrl.contains(";base64,")) {
String[] tmp = iconUrl.split(",");
image = PluginUtil.getBitmapFromBase64encodedImage(tmp[1]);
} else {
- AssetManager assetManager = cordova.getActivity().getAssets();
- InputStream inputStream;
try {
+ InputStream inputStream;
+ if (iconUrl.startsWith("/")) {
+ File file = new File(iconUrl);
+ inputStream = new FileInputStream(file);
+ } else {
+ AssetManager assetManager = cordova.getActivity().getAssets();
inputStream = assetManager.open(iconUrl);
+ }
image = BitmapFactory.decodeStream(inputStream);
inputStream.close();
} catch (IOException e) {

Bug fix: Can not load image with file:// protocol (Issue #1668)