-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Hello, first thank you very much for upgrading the library. The nativescript community is amazing and very glad to see it constantly evolve and being maintained.
I think I found a bug. The contract changed slightly with mapbox sdk v11+ in Android for addImage as it seems its expecting to be wrapped by a ImageExtensionImpl builder before providing the image.
Therefore I was getting this error when trying to add an image in mapbox sdk
Error: java.lang.NoSuchMethodError: no static method "Lcom/mapbox/maps/MapboxStyleManager;.addImage(Ljava/lang/String;Landroid/graphics/Bitmap;)Lcom/mapbox/bindgen/Expected;
After debugging the problem I figured out reading the very clear documentation about the migration (this was a sarcasm of course)
I could not find any other reference that properly cast the image it seems like
style.addImage('id', imageBitMap)
should be supported but in my case it looks like the signature did not match thus crashed consistently.
So I got a proposition to fix this issue from reverse engeneering the implementation but I suspect this is not the proper way.
@nativescript-community/ui-mapbox/index.android.js
In addImage I changed :
const imageSource = await this.fetchImageSource(imagePath);
theMap.getStyle().addImage(imageId, imageSource.android);
To
const imageSource = await this.fetchImageSource(imagePath);
const bitmap = imageSource.android;
const ImageExtensionImpl = com.mapbox.maps.extension.style.image.ImageExtensionImpl;
const imageBuilder = new ImageExtensionImpl.Builder(imageId, bitmap);
const image = imageBuilder.build();
image.bindTo(theMap.getStyle());
resolve();
making sure that the bitmap is properly casted.
If anyone has a better solution or if I am totally mistaken let me know thank you.