nativescript-community / nativescript-community/ui-mapbox
addImage bug in v7.0.12 for android
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 38
- Forks
- 26
- PR merge metrics
- No merged PRs in 30d
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in @nativescript-community/ui-mapbox/index.android.js, focusing on addImage and its fetchImageSource call. Compare the current Mapbox Android SDK v11 style-image API with the direct addImage invocation and verify the corrected behavior against the reported NoSuchMethodError. Done means images can be added on Android without the signature crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, typescript
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100