cordova-plugin-googlemaps icon indicating copy to clipboard operation
cordova-plugin-googlemaps copied to clipboard

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

Open CodeWithOz opened this issue 2 years ago • 1 comments

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.

CodeWithOz avatar Nov 02 '21 01:11 CodeWithOz

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.

tryhardest avatar Feb 11 '22 23:02 tryhardest