Image uploaded in Mapbox Studio returns nil above Mapbox SDK version 11.8.0
Environment
- Xcode version: 16.0.0
- iOS version: All versions
- Devices affected: All devices
- Maps SDK Version: 11.9.0, 11.10.0
Observed behavior and steps to reproduce
- Upload an image in Mapbox Studio
- Now try to access image using ID
mapView?.mapboxMap.image(withId: "<image ID here>")// returns nil.
Expected behavior
UIImage object should return from styleManager.
Notes / preliminary analysis
- Observed this issue after Mapbox SDK version upgraded to 11.9.0 or 11.10.0 from 11.8.0 version.
Additional links and references
Image uploaded in Studio.
Same behaviour in SwiftUI :
proxy.map?.image(withId: pinFeature.imageIcon) returns nil.
Also false returns for
public func imageExists(withId id: String) -> Bool { return styleManager.hasStyleImage(forImageId: id) }
Hi @jeevan2628 --
I'm not able to reproduce this issue on my side. Are you sure you've added the new image to the correct style?
Yes @pjleonard37 It is uploaded to correct style. It got this issue after upgrading SPM package version to 11.10.0 from 11.8.0. No other code or configuration changes done.
May I know which method you are using to get image from studio ?
For example, mapView?.mapboxMap.image(withId: "mountain") is not working for me.
Also not able to understand below log where image is nil even though it says image exists :
Hi @jeevan2628 -
Thanks for the additional info. I've reproduced this on my side now and we're investigating.
Hi @jeevan2628 --
Can you share more details about your use case? Once you get the "location_star" image returned from mapView?.mapboxMap.image(withId: "location_star") what are you doing with it?
Hi @pjleonard37 ,
Once I get UIImage from mapView?.mapboxMap.image(withId:), I will set the image for my custom annotation view icon like below :
// Load the image from Mapbox style and set icon for CustomAnnotationView
customAnnotationView.setImageForIcon(mapView?.mapboxMap.image(withId: "location_star"))
In CustomAnnotationView the image will set to iconView i.e an UIImageView.
func setImageForIcon(_ image: UIImage?) {
iconView.image = image
}
Please let me know if you need any further information. Thank you !.
Hi @pjleonard37 ,
Upgraded to v11.12.0-beta.1 based on the feature list given the release notes #3. Vector icons can now also be retrieved via getStyleImage. , now the issue got resolved in UIKit. 🎉🚀✨. But i still see the issue in SwiftUI code. Great if you could confirm works for both frameworks.
Please go ahead & close this bug ticket. Thanks for all supports !!
Hi @jeevan2628 --
Yes, we're working on this. I'm glad to hear it is working for you in UIKit now. Can you share your SwiftUI code so we can repro the issue on our side?
FYI in SwiftUI, i have below view
MapReader { proxy in
Map(viewport: $viewPort) {
// Loops pin features and creates custom pins below
MapPinView(annotationDataSource: pinFeature,
iconImage: proxy.map?.image(withId: pinFeature.imageIcon ?? ""),
handlePinTap: { /* Code for handling tap*/ }
// Rest of the code
}
}
PS: I have not tried with latest version. I will check and let you all know here.