Welcome to day 70 of the 100 Days of SwiftUI! We’ve arrived at the final 30 days and are slowly but surely reaching the end of the course. Yesterday, we focused on MapKit and biometric authentication. Today, we’re further expanding the MapKit implementation by adding more useful features to the Bucket List app. Let’s take a look!
Adding user locations to a map in SwiftUI
This project is going to be based around a map view, asking users to add places to the map that they want to visit. To do that we need to place a Map
so that it takes up our whole view, track its center coordinate, and then also whether or not the user is viewing place details, what annotations they have, and more.
After following Paul’s guide and running the app, you should be able to move around the map freely and press the + button to add a new location.
Improving our map annotations
Right now we’re using
Hacking with Swift, Paul Hudson (@twostraws)MapMarker
to place locations in ourMap
view, but SwiftUI lets us place any kind of view on top of our map so we can have complete customizability. So, we’re going to use that to show a custom SwiftUI view containing an icon and some text to show the location’s name, then take a look at the underlying data type to see what improvements can be made there.
SwiftUI makes this quite easy thankfully.
Wrap up
And that’s it for day 70! We’ll keep on going tomorrow as we look to add data from Wikipedia to our app, which should be very interesting to implement. For now, it’s high time to recharge.
100 Days of SwiftUI – Day 70