mapbox-maps-ios icon indicating copy to clipboard operation
mapbox-maps-ios copied to clipboard

Image uploaded in Mapbox Studio returns nil above Mapbox SDK version 11.8.0

Open jeevan2628 opened this issue 10 months ago • 8 comments

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

  1. Upload an image in Mapbox Studio
  2. 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. Image

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) }

jeevan2628 avatar Mar 07 '25 15:03 jeevan2628

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?

pjleonard37 avatar Mar 10 '25 16:03 pjleonard37

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 :

Image

jeevan2628 avatar Mar 11 '25 17:03 jeevan2628

Hi @jeevan2628 -

Thanks for the additional info. I've reproduced this on my side now and we're investigating.

pjleonard37 avatar Mar 17 '25 19:03 pjleonard37

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?

pjleonard37 avatar Mar 21 '25 13:03 pjleonard37

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 !.

jeevan2628 avatar Mar 21 '25 14:03 jeevan2628

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 !!

jeevan2628 avatar Apr 11 '25 10:04 jeevan2628

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?

pjleonard37 avatar Apr 15 '25 20:04 pjleonard37

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.

jeevan2628 avatar May 15 '25 08:05 jeevan2628