Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. iOS
  4. How to focus on a specific location by using google maps.

How to focus on a specific location by using google maps.

Scheduled Pinned Locked Moved iOS
databasetutorialquestion
1 Posts 1 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Asim Gunduz
    wrote on last edited by
    #1

    Hi, I want to pass coordinates from FirstVC to my SecondVC. and inside the SecondVC which holds MyMap I want the map to show the coordinates I've sent from the FirstVC to do this Here is what I did. SecondVC

    override func viewDidLoad() {
    super.viewDidLoad()

    //Mapview Settings.
    self.MyMapView.delegate = self
    self.MyMapView.isMyLocationEnabled = true
    self.MyMapView.settings.myLocationButton = true
    

    }

    I have this Function

    func InitGoogleMaps(pMyMapInf:MyMapInf){

    if (pMyMapInf.IsEmpty)
    {
        return
    }
    
    let camera = GMSCameraPosition.camera(withLatitude: pMyMapInf.MyDestinLongitute, longitude: pMyMapInf.MyDestinLongitute, zoom: 6.0)
    let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
    MyMapView = mapView
    MyMapView.isMyLocationEnabled  = true
    self.MyMapView.camera = camera
    
    // Creates a marker in the center of the map.
    let marker = GMSMarker()
    marker.position = CLLocationCoordinate2D(latitude: pMyMapInf.MyDestinLatitude, longitude: pMyMapInf.MyDestinLongitute)
    marker.title = pMyMapInf.MyDestinCity
    marker.snippet = pMyMapInf.MyDestinCountry
    
    
    print("Latitude is: \\(pMyMapInf.MyDestinLatitude) ")
    print("Longitude is: \\(pMyMapInf.MyDestinLongitute) ")
    print("City is: \\(pMyMapInf.MyDestinCity) ")
    print("Country is: \\(pMyMapInf.MyDestinCountry) ")
    
    marker.map = mapView
    
    MyMapView.animate(to: camera)
    

    }

    And I have this Observer to trigger the above function.

    var MyMapInfo:MyMapInf = MyMapInf()
    {
    didSet{
    InitGoogleMaps(pMyMapInf: MyMapInfo)
    }
    }

    so what happens is: on my FirstVC I create a new instance of MyMapInf()

    var loFVcMyMapInf = MyMapInf()
    SecondVC.MyMapInfo = loFVcMyMapInf

    and I present the SecondVC(or I present the SecondVC then set didset observer , When this happens I see that my function is triggered and I see the values I print on the console, however, there ain't any movements on the map or a marker. it's still what am I missing here?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups