Build a Maps Application in SwiftUI - Find Nearby Landmarks
HTML-код
- Опубликовано: 18 сен 2024
- In this video, Mohammad Azam will demonstrate how to build a maps application in SwiftUI which will display landmarks near the user's current location. Azam will also show how to use a single source of truth and update the views based on user's selection.
GitHub: github.com/aza...
#iosdev #swiftui #swiftuilocation #swiftuimaps
If you liked this video and want to support my channel then check out my courses below:
azamsharp.com/... Check out my courses at
azamsharp.school/
Great beginning of an app Mo! I added an xmark.circle.fill to the search field to clear it. Also used focusState to refocus on the search field after clearing and .removeAll() on the search array that populates the List. Also plan to add distance from my location to the points of interest. The search can find streets, any POI, and lots more. Thanks for the great MapKit structure!
how is it coming along??
Wow! Thank you so very very much! For me you covered a lot of ground in both technique and with SwiftUI/MapKit. Very clear and concise.! Thanks again; Worked great following along
This is the video I've been looking for. I cannot overstate the help this has provided. Thanks so much!
As usual, excellent always. This code as is with Xcode 14.2, I am getting this warning: "Publishing changes from within view updates is not allowed, this will cause undefined behavior.". I know this showed up as a new warning, and Rebeloper published a work around. I think, it will be nice to hear a proper fix than a workaround.
Great as always. How would you implement map overlay? UIViewRepresentable? Maybe idea for next video.
Great video, I learned a lot of stuff.
Thank you so much Mohamed
Thanks!
Hi, nice video, can you just explain a solution for the warning "Publishing changes from within view updates is not allowed, this will cause undefined behavior." thanks
Outstanding video sir! Can you share the code to unwrap the CLLocationCoordinate2D in Landmark to provide a Double to share in an array stored in Firebase? Thanks so much for sharing this outstanding video!!
Thank you so much for this video! Been looking for this map help!
btw, would you have any instructions on how to add firebase code to the map? Outside of the regular setup with Firebase and SDK to iOS, how would one allow the map data to flow to firebase?
e.g.
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let location = locations.last else { return }
let fireDatabase = Firestore.firestore()
DispatchQueue.main.async { [weak self] in
self?.region = MKCoordinateRegion(center: location.coordinate, span: MKCoordinateSpan(latitudeDelta: 0.25, longitudeDelta: 0.25))
}
}
How could one include "let fireDatabase" into LocationManager?
Apologies for asking specifics...
Instead of using a Textfield to search for a specific Landmark, what would you put in the search query to automatically search for all landmarks in the current location?
sir how are you researching and learning these all
Very good tutorial. What part do I need to change to be able to search the user's current location instead of Cupertino CA? I tried it on the device and it keeps searching Cupertino. You can of course be more specific on the search by including the name of the city you're in but is there a way to automatically searches in the user's current location?
You will have to use LocationManager to get the location. Try to run it on real device and I think it will show correct location.
@@azamsharp Never mind, I didn't have one of the Privacy - keys spelled correctly so it wasn't asking for permission. It's now working great. Thanks a lot for the good tutorial.
I had downloaded the repo. I am getting several warnings. Could you please check if it is happening with you as well?
Publishing changes from within view updates is not allowed, this will cause undefined behavior.
Yeah. I was never able to solve that issue.
i m a complete beginner but i know java , i tried swift ui it ok but how can be more skilled in implementing new things by researching can you make a video on it how you are researching and learning new things.
azamsharp.com/2022/11/06/complete-guide-ios-dev-2023.html
I am getting thousands of purple warnings 'Publishing changes from within view updates is not allowed, this will cause undefined behavior.' so much that Xcode is lagging or freezing. Any idea how I can fix that?
I was never able to solve those warnings.
@@azamsharp I'd be grateful if you share here with us, to find a way to get rid of those thousands of purple warnings.
@@omursenocak2267 I was never able to figure out the reason for the warnings.
Hello, I'm getting this error:
Thread 1: Fatal error: No ObservableObject of type LocalSearchService found. A View.environmentObject(_:) for LocalSearchService may be missing as an ancestor of this view.
in ContentView
Can you help? Thanks!
in the Preview section add. ContentView().environmentObject(LocalSearchService())
e.g.
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView().environmentObject(LocalSearchService())
}
}
Thanks for tutoring . But there One error needs to resolve .. Publishing changes from within view updates is not allowed, this will cause undefined behavior.. Into LocalSearchService . even wrapping with @MainActor does not solve the warning