How to get current user's location and add a Marker in Apple Maps in Swift 5?

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.พ. 2025
  • Maps Series: Tutorial 3 📝
    Tutorial 1 Link: • How to get current use...
    Tutorial 2 Link: • How to use Places API ...
    In this tutorial we'll see how to capture the current user's location add a Marker in Apple Maps in your Swift Project.This tutorial is the third in the series of implementing various types of Maps in Swift, so make sure you have subscribed 👆to our channel and you have hit the notification button 🔔
    📌Updating info.plist file with Privacy settings for Location from 01:06
    📌Adding Apple Map from 02:44
    📌Adding CLLocationManagerDelegate from 03:31
    📌Adding and Configuring Location Manager from 03:44
    📌Adding Location Manager didupdatelocations from 06:09
    📌Adding a Span MKCoordinateSpan from 09:19
    📌Adding a Region MKCoordinateRegion from 11:29
    📌Adding Map Annotation MKPointAnnotation from 12:39
    📌Adding the locationManagerDidChangeAuthorization stub from 14:41
    📌Demo, Showing a Apple Map with the current user's location and Map Annotation 18:30
    We upload new videos every week!
    Please reach out to me on the comments section if you have any doubts on this topic. Also, please Like & Subscribe the Channel and help us being part of your journey to learn Swift. Cheers until the next video!
    #LocationManager#AppleMaps #Annotation #Swift

ความคิดเห็น • 9

  • @whizpooldevelopment5376
    @whizpooldevelopment5376 3 ปีที่แล้ว

    Hi... !! this tutorial is very helpful for me ... thanks for the tutorial ...

  • @al-amin1692
    @al-amin1692 3 ปีที่แล้ว

    Hi. You're doing great job. It will be helpful if you make videos about Core Animation. Hope you will cover some advance topics in upcoming days.

    • @RDLabswithRohant
      @RDLabswithRohant  3 ปีที่แล้ว

      Thank you for your support! We will get there soon!

  • @whizpooldevelopment5376
    @whizpooldevelopment5376 3 ปีที่แล้ว +1

    2ndly I want something like changing the icon of the pin in the apple map kit ... where as we can change the pin easily in the google maps ... can we change the pin icon (marker) in the Apple Maps ...? if yes plz comment

    • @RDLabswithRohant
      @RDLabswithRohant  3 ปีที่แล้ว

      Yes you can. Below is the code for that:
      FIRST: Set the delegate of the MapView to Self in viewdidload()
      myMap.delegate = self
      SECOND: Add MKMapViewDelegate to the Class
      THIRD: Copy these lines of code to your Class. The Pin will change itself to a black circle dot.
      func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
      if !(annotation is MKPointAnnotation) {
      return nil
      }
      let annotationIdentifier = "AnyName"
      var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: annotationIdentifier)
      if annotationView == nil {
      annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier)
      annotationView!.canShowCallout = true
      }
      else {
      annotationView!.annotation = annotation
      }
      let pinImage = UIImage(systemName: "circle.fill")
      annotationView!.image = pinImage
      return annotationView
      }

    • @whizpooldevelopment5376
      @whizpooldevelopment5376 3 ปีที่แล้ว

      @@RDLabswithRohant that will be great ... thanks

  • @jae19882005
    @jae19882005 3 ปีที่แล้ว

    Do you know how to drop marker and get the user to describe what it is as a user on the app?

    • @RDLabswithRohant
      @RDLabswithRohant  3 ปีที่แล้ว

      Hello James, One must use the PlacesAPI for this to happen. This calls for me to do a video on this subject