mapsplugin / cordova-plugin-googlemaps

Google Maps plugin for Cordova
Apache License 2.0
1.66k stars 913 forks source link

Add logic to decode marker image bytes a second time if first decode returns `null` bitmap #2890

Open CodeWithOz opened 2 years ago

CodeWithOz commented 2 years ago

Please tell us your new feature idea It would be nice to add handling for the possibility of marker images that have been encoded twice in base64.

Why do you need it? Some servers unintentionally encode base64 images twice, so the image has to be decoded twice before the binary data is accessible. Browsers already handle this seamlessly. This image is an example of an image that is encoded twice on the server, and you can see that it loads without issues in the browser. But if you try using it as a marker icon with this plugin, it fails and the default red marker pin shows instead.

How helps other people? Right now the developer has to either change the server config (which is not always straightforward and can be hard to do correctly) or fork the plugin and add the extra decoding step to get the image to show correctly.

tryhardest commented 2 years ago

Would anyone (maybe @wf9a5m75 ) who knows Java be able to offer assist here. Same for us.

Wondering if getting the instance of Base64.Decoder and use it to decode the base 64 encoded string would work

String encodedString = "dXNlcm5hbWU6cGFzc3dvcmQ=";
Base64.Decoder decoder = Base64.getDecoder();

byte[] decodedByteArray = decoder.decode(encodedString);

//Verify the decoded string
System.out.println(new String(decodedByteArray));

Output
username:password

Not sure if this would work, and then probably would need an implementation for Obj-C and iOS as well.