capacitor-community / google-maps

Capacitor Plugin using native Google Maps SDK for Android and iOS.
https://capacitor-community.github.io/google-maps/
MIT License
152 stars 64 forks source link

Map does not longer work on Android #225

Closed Anokino closed 1 year ago

Anokino commented 1 year ago

Hello, My code that used to work on both web and android doesn't work anymore on android.

In the android debug console, I have a resize event that produces an error. I don't know if this is related:

native CapacitorGoogleMaps.onResize (#6561217)
{callbackId: '6561217', pluginId: 'CapacitorGoogleMaps', methodName: 'onResize', options: {…}}
tab2꞉5:32:306
callbackId:
'6561217'
methodName:
'onResize'
options:
{id: 'my-cool-map', mapBounds: {…}}
pluginId:
'CapacitorGoogleMaps'
[[Prototype]]:
Object

and the error :

result CapacitorGoogleMaps.onResize (#6561217)
{message: 'Map not found for provided id.', code: '2'}
tab2꞉5:32:281
Unhandled Promise rejection: Map not found for provided id. ; Zone: <root> ; Task: Promise.then ; Value: Error: Map not found for provided id.
    at returnResult (:857:32)
    at win.androidBridge.onmessage (http://192.168.10.20:8100/tabs/tab2:832:21) {code: '2', data: undefined, stack: 'Error: Map not found for provided id.
    at … (http://192.168.10.20:8100/tabs/tab2:832:21)', message: 'Map not found for provided id.'} Error: Map not found for provided id.
    at returnResult (:857:32)
    at win.androidBridge.onmessage (:832:21)

Anyway, the page is displayed, with the map location but not the map displayed.

On web :

image

On Android :

image

I'm using Ionic 7 and the latest version of the plugin, my APIKey is also in the AndroidManifest, and i have restriction on my ApiKey. Here is the fragment of code of the map page :

async createMap() {
    const apiKey = "_...removed for evident reason..._";
    const mapRef = document.getElementById('map')!

    this.newMap = await GoogleMap.create({
      id: 'my-cool-map',
      element: mapRef,
      apiKey: apiKey,
      config: {
        center: {
          lat: 46.513605,
          lng: -1.7696065,
        },
        zoom: 12.30,
      }
    });
Anokino commented 1 year ago

Sorry, I just noticed a bit late that I'm not in the right repo because I'm using @capacitor/google-maps and not capacitor-community.