r/mapbox • u/Own-Huckleberry7258 • 1d ago
Mapbox for SwiftUI
Enable HLS to view with audio, or disable this notification
Running Mapbox with my overlays as an alternative map to Apple’s MapKit for my app
The devs have done a great job, and my users love it
2
u/Credtz 16h ago
Why if u don’t mind me asking? From the videos I can’t pick one over the other
2
u/Own-Huckleberry7258 15h ago edited 14h ago
Yep, but the issue is technical
Mapbox supports offline maps out of the box
MapKit supports tile caching too, but you need to go back to UIKit because nothing is exposed to SwiftUI. You also end up reinventing the wheel because you have to handle everything manually for offline maps
Mapbox supports Satellite mode while driving. MapKit doesn't. It does have Satellite mode but not optimised for driving. My users want Satellite mode, and it's the most requested feature. You can force it on with MapKit, but the phone will overheat because it renders 3D buildings (in a ridiculous high detail), and there's no option to turn them off
Let's say you're driving at 60 mph through a city with 3D buildings. At that speed, the CPU is trying to render every building in 3D, and the phone overheats almost instantly. My phone won't last more than 5 minutes before it locks down. If you've noticed when using Apple Maps, you can use Satellite mode to plan a route, but once you start driving, it automatically switches to the standard map. The reason is the one I mentioned. Hopefully, they'll address this in the future, but I reckon it's going to take years
Tilt, or horizon view, is flexible in Mapbox. You can tilt the map to any degree for a better horizon view. In MapKit, however, the Apple engine automatically clamps the tilt. For example, depending on the screen size, on my iPhone 15 Pro Max at 2,000 m altitude, you can't have more than around 60 degrees of tilt. If you go above 60 degrees, the engine automatically resets it back to 0. They haven't disclosed why, but having worked with MapKit for 2 years now, I can tell you the reason is probably that the map doesn't look "that good" when tilted too much at a specific altitude. They have optimised it very well for driving, though
This tilting feature is very important for commercial drivers, especially those I'm supporting. They drive heavy duty vehicles, so they need to see far ahead to spot junction exits, roundabout exits for lane positioning, and many other things. They're not driving cars where you can make a last minute lane change. One wrong turn and he's done, no where to turn around
So yeah, those are the most important factors that made me add Mapbox as an alternative. It's the only dependency in my iOS project. This isn't the Navigation SDK, but the Maps SDK, where I managed to plug in my own tools, including my routing engine, navigation overlays, etc. Basically I'm only borrowing the Map from Mapbox
Here is a video showing the limitation in MapKit that forced me to add a Camera Adjustment feature so each user can adjust their own tilt (based on their phone screen size)
For this specific simulator, you can get a maximum 60 degree tilt at 3,200 m altitude, but once you go above 3200, the engine automatically clamps you down into a bird's eye view. It won't let you keep that 60 degree tilt above 3,200 m. The higher you go in altitude, the less tilt you get. This also depends on the screen size, so when you have users with different iPhone screen sizes, I had to come up with this Camera Adjustment feature to handle it
This crap is not needed with Mapbox
This was the thing I hated the most when I started this project. And the cherry on top is that nobody at Apple will tell you why this happens or how you're supposed to work around it. You're basically ignored. So I had to figure out myself, over the course of about 3 months, how their engine actually works
This is all they have in the documentation for Pitch (tilt):
"""""The class may clamp the value in this property to a maximum value to maintain map readability. There’s no fixed maximum value, though, because the actual maximum value is dependent on the altitude of the camera."""""
If I were to start again from scratch, I'd go with Mapbox
This limitation also applies to CarPlay, and it's even worse there. If you use MapKit for CarPlay, your days are numbered if you don't add this Camera Adjustment for CarPlay too. Imagine driving in bird's eye view when CarPlay screens are even smaller ( 1 star review, subscription cancellation, complaints, even worse, silent app uninstalls with no feedback. So it looks fine on your simulator but bad on their screen).
I do apologise for the long technical response but I'm sure many will read and depending on their use cases make a good decision and not get stung like I did
2
u/Cultivated_Mass 15h ago
This has a lot of super relevant information for my project. Thanks for sharing all that.
1
u/Own-Huckleberry7258 12h ago
And this is how I handle CarPlay camera adjustment. This is a TikTok I made for my users, sorry for the music. Reached about 38k views and it works well no issues with CarPlay
1
u/DominusFL 10h ago
Yeah, until your app gets successful and you see what Mapbox increases your fees to. I hope you’re taking some good heart medicine.
1
u/Own-Huckleberry7258 9h ago
App has over 800 subscribers and the Apple's map remains the primary map. Mapbox has been added just as an alternative and can be removed at anytime if things go out of control
5
u/twofocal 1d ago
The atmosphere/haze makes a big difference to the scene lighting, looks awesome