ios-maps-sdk icon indicating copy to clipboard operation
ios-maps-sdk copied to clipboard

Delegate function not being called (swiftUI)

Open dan007b3 opened this issue 1 year ago • 4 comments

Environment details

XCode Version 15.4 deployment target: 17.5 Google Maps SDK using Swift Package Manager Swift UI

Steps to reproduce

I have been trying to get the delegate function:

func mapView(
        _ mapView: GMSMapView,
        didTapPOIWithPlaceID placeID: String,
        name: String,
        location: CLLocationCoordinate2D
    )

but nothing happens when i tap a POI, so I tried it again using the demo code provided by google and still nothing. other delegate functions are being called. So I don't really know what the problem is. Maybe using UIViewController in swiftUI to use causing issues?

Code example

import GoogleMaps

class TestMapViewController: UIViewController, GMSMapViewDelegate {
    
    override func loadView() {
        let camera = GMSCameraPosition.camera(
            withLatitude: 47.603,
            longitude:-122.331,
            zoom:14
        )
        let mapView = GMSMapView.map(withFrame: .zero, camera: camera)
        mapView.delegate = self
        self.view = mapView
    }
    
    
    
    func mapView(
        _ mapView: GMSMapView,
        didTapPOIWithPlaceID placeID: String,
        name: String,
        location: CLLocationCoordinate2D
    ) {
        print("You tapped \(name): \(placeID), \(location.latitude)/\(location.longitude)")
    }
}

dan007b3 avatar Aug 18 '24 14:08 dan007b3

In my project, I noticed that -mapView(_:didTapPOIWithPlaceID:name:location:) is consistently called on the first launch of the app. However, on subsequent launches, the delegate function stops being called. Deleting the app and reinstalling it makes the delegate function work again, suggesting that some state is being stored that prevents the delegate from being triggered after the first launch.

After investigating, I found that deleting the Application Support/com.google.GoogleMaps/ServerControlledParams file (see screenshot below) resolves the issue. It seems like something in the Google Maps SDK's server-controlled parameters might be preventing the delegate function from being called on later launches.

I have the "Maps SDK for iOS" API enabled in Google Cloud, but I wonder if there's an additional API or setting needed to (reliably) access POIs.

Screenshot 2024-09-13 at 05 45 14

simonbs avatar Sep 13 '24 03:09 simonbs

Hey, I have the same issue on UIKit version of the app. The steps provided by @simonbs are working for me - the poi delegate call works only on first launch after fresh install of the app.

Environment details XCode Version 16.0 deployment target: 16.0 Google Maps SDK using Swift Package Manager (9.1.1) UIKit

Is there any ticket already reported on this issue? When can we expect this bug to be resolved?

edit: Found this: https://issuetracker.google.com/issues/364913805

SzymonMatysik avatar Sep 26 '24 10:09 SzymonMatysik

@simonbs Did you find roote cause or any stable workaround for this defect?

kishanmadhu avatar Oct 01 '24 13:10 kishanmadhu

According to Google's Issue Tracker:

Oct 8, 2024 07:21AM
Marked as fixed.
We greatly appreciate your patience.

A fix for this issue has been made internally and will be available in the next release.

No new releases since then. I guess we wait...

davidvypark avatar Nov 05 '24 11:11 davidvypark