Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: on Ionic 7, capacitor 6.0.1 IOS googlemaps.create() fails, but doesn't return an error, worked on prior releases #7820

Open
1 of 3 tasks
sdetweil opened this issue Dec 28, 2024 · 1 comment
Labels

Comments

@sdetweil
Copy link

sdetweil commented Dec 28, 2024

Capacitor Version

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 6.2.0
@capacitor/core: 6.2.0
@capacitor/android: 6.2.0
@capacitor/ios: 6.2.0

Installed Dependencies:

@capacitor/cli: 6.2.0
@capacitor/ios: 6.0.0
@capacitor/android: 6.0.0
@capacitor/core: 6.0.0

[success] iOS looking great! 👌
[success] Android looking great!

Other API Details

npm version 

 npm: '10.8.2',
  node: '18.20.5',
  acorn: '8.13.0',
  ada: '2.8.0',
  ares: '1.29.0',
  base64: '0.5.2',
  brotli: '1.1.0',
  cjs_module_lexer: '1.2.2',
  cldr: '44.1',
  icu: '74.2',
  llhttp: '6.1.1',
  modules: '108',
  napi: '9',
  nghttp2: '1.61.0',
  nghttp3: '0.7.0',
  ngtcp2: '1.3.0',
  openssl: '3.0.15+quic',
  simdutf: '5.6.0',
  tz: '2024a',
  undici: '5.28.4',
  unicode: '15.1',
  uv: '1.44.2',
  uvwasi: '0.0.19',
  v8: '10.2.154.26-node.37',
  zlib: '1.3.0.1-motley'

node -v 
18.20.5

pod --version output 
1.16.2

in podfile.lock
  - CapacitorGoogleMaps (6.0.1):
    - Capacitor
    - Google-Maps-iOS-Utils (~> 5.0)
    - GoogleMaps (~> 8.4)
  - CapacitorHaptics (6.0.0):
    - Capacitor
  - CapacitorKeyboard (6.0.0):
    - Capacitor
  - CapacitorNetwork (6.0.0):
    - Capacitor
  - CapacitorPreferences (6.0.0):
    - Capacitor
  - CapacitorScreenReader (6.0.0):
    - Capacitor
  - CapacitorStatusBar (6.0.0):
    - Capacitor
  - CordovaPlugins (6.2.0):
    - CapacitorCordova
  - Genericuwbplugin4 (0.0.1):
    - Capacitor
  - Google-Maps-iOS-Utils (5.0.0):
    - GoogleMaps (~> 8.0)
  - GoogleMaps (8.4.0):
    - GoogleMaps/Maps (= 8.4.0)
  - GoogleMaps/Base (8.4.0)
  - GoogleMaps/Maps (8.4.0):
    - GoogleMaps/Base

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

[log] - in create map
⚡️ [log] - have ref
To Native Cordova -> Geolocation getLocation Geolocation1810295179 ["options": [0, 0]]

This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the -locationManagerDidChangeAuthorization: callback and checking authorizationStatus first.
⚡️ [log] - have current position for map={
"coords": {
"latitude": 30.46355392733366,
"longitude": -97.62859466229018,
"accuracy": 26.689875241230123,
"altitude": 237.3172779083252,
"heading": null,
"speed": null,
"altitudeAccuracy": 11.927132606506348
},
"timestamp": 1735414885968.9688
}
with try/catch
⚡️ [log] - ready to open map=
⚡️ [log] - map create error= {}

"timestamp": 1735415657940.414
}
without try/catch
⚡️ [log] - ready to open map=

code called from created()
zoomLevel = 15

        async createMap() {
            console.log("in create map");
            const mapRef = document.getElementById('map');
            console.log("have ref")
            // locate where we are 
            const pos = await Geolocation.getCurrentPosition({ options: { maximumAge: 5 * 60000, timeout: 5000, enableHighAccuracy: false } })
            console.log("have current position for map="+JSON.stringify(pos,null,2))
            this.currentMapCenter.lat = pos.coords.latitude
            this.currentMapCenter.lng = pos.coords.longitude
            console.log("ready to open map=")
            try {
                this.newMap = await GoogleMap.create({
                    id: 'my-map', // Unique identifier for this map instance
                    element: mapRef, // reference to the capacitor-google-map element
                    apiKey: API_KEY, // Your Google Maps API Key
                    config: {
                        center: {
                            // The initial position to be rendered by the map
                            lat: this.currentMapCenter.lat,
                            lng: this.currentMapCenter.lng
                        },
                        zoom: this.zoomLevel, // The initial zoom level to be rendered by the map
                    }

                }, (mapid) => {
                    console.log("map is ready, id=" + mapid)
                });
                console.log("map is " + this.newMap ? "ready" : "not ready")
                if (this.newMap != null) {
                    console.log("map created")
                    // add a callback for position changed/zoom level 
                    this.newMap.setOnBoundsChangedListener(this.zoomChanged);
                    this.newMap.setOnMarkerClickListener(this.markerClicked);
                    this.newMap.enableTrafficLayer(true);
                    this.newMap.enableAccessibilityElements(true);
                    this.newMap.enableCurrentLocation(true);
                    console.log("callback set")

                    // call api with location and range, to get points out of database
                    let markerList = []
                    // makerList=await this getInRangeLocations(this.zoomLevel,this.currentMapCenter)
                    markerList.push({
                        coordinate: {
                            lat: this.currentMapCenter.lat,
                            lng: this.currentMapCenter.lng,
                        },
                        title: "current location"
                    })
                    console.log("marker list=" + JSON.stringify(markerList))
                    try {
                        await this.newMap.addMarkers(markerList)
                        console.log("markers added");
                    } catch (error) {
                        console.log("add markers error=" + JSON.stringify(error))
                    }
                } else {
                    console.log("map was null")
                }
            } catch (error) {
                console.log("map create error=",error)
            }
        }

Expected Behavior

used to work .

Project Reproduction

no idea yet

Additional Information

i looked in wiki, closed issues, open issues for maps.

@sdetweil
Copy link
Author

spent some more time, created a onViewDidEnter

⚡️  To Native ->  CapacitorGoogleMaps create 45458684
⚡️  TO JS undefined
⚡️  To Native ->  CapacitorGoogleMaps addListener 45458685
⚡️  [log] - ready
⚡️  [log] - map created
⚡️  [log] - callback set
⚡️  To Native ->  CapacitorGoogleMaps addListener 45458686
⚡️  To Native ->  ⚡️  [log] - marker list=[{"coordinate":{"lat":30.46355392733366,"lng":-97.62859466229018},"title":"current location"}]
CapacitorGoogleMaps addListener 45458687
⚡️  To Native ->  CapacitorGoogleMaps enableTrafficLayer 45458688
⚡️  To Native ->  CapacitorGoogleMaps enableAccessibilityElements 45458689
⚡️  To Native ->  CapacitorGoogleMaps enableCurrentLocation 45458690
⚡️  To Native ->  CapacitorGoogleMaps addMarkers 45458691
CapacitorGoogleMaps/Map.swift:448: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
func enableTrafficLayer(enabled: Bool) throws {
    DispatchQueue.main.sync {
        self.mapViewController.

GMapView <---- this is null
.isTrafficEnabled = enabled
}
}

these methods all crash

                    await this.newMap.enableTrafficLayer(true);
                    await this.newMap.enableAccessibilityElements(true);
                    await this.newMap.enableCurrentLocation(true);
                    await this.newMap.setMapType(MapType.Hybrid)

supposedly the GMapView is set

    override func viewDidLoad() {
        super.viewDidLoad()

        let camera = GMSCameraPosition.camera(withLatitude: cameraPosition["latitude"] ?? 0, longitude: cameraPosition["longitude"] ?? 0, zoom: Float(cameraPosition["zoom"] ?? 12))
        let frame = CGRect(x: mapViewBounds["x"] ?? 0, y: mapViewBounds["y"] ?? 0, width: mapViewBounds["width"] ?? 0, height: mapViewBounds["height"] ?? 0)
        if let id = mapId {
            let gmsId = GMSMapID(identifier: id)
            self.GMapView = GMSMapView(frame: frame, mapID: gmsId, camera: camera)
        } else {
            self.GMapView = GMSMapView(frame: frame, camera: camera)
        }

        self.view = GMapView   // should this be self.GMapView?  as GMapView isn't defined or set 
    }

setCamera also failed

⚡️  To Native ->  CapacitorGoogleMaps setCamera 33395440
CapacitorGoogleMaps/Map.swift:407: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value

if I comment them out, i can add markers, but the map doesn't appear..

oh, this is Vue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant