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

TypeError: Cannot read properties of undefined (reading 'map') #189

Closed bstrasburg closed 2 years ago

bstrasburg commented 2 years ago

Describe the bug Many times on refresh I get this error

To Reproduce Copy your code from : https://capacitorjs.com/docs/apis/google-maps#addmarkers

run in web and then refresh the page

Screenshots

image image
mujie-dm commented 2 years ago

Describe the bug Many times on refresh I get this error

To Reproduce Copy your code from : https://capacitorjs.com/docs/apis/google-maps#addmarkers

run in web and then refresh the page

Screenshots image

image

First, please differentiate between '@capacitor-community/capacitor-googlemaps' and '@capacitor/google-maps'.

I was successfully add a marker with @capacitor-community/capacitor-googlemaps.

import { CapacitorGoogleMaps } from '@capacitor-community/google-maps';

const mymarker = await CapacitorGoogleMaps.addMarker({
      mapId: document.getElementById("map").getAttribute("data-maps-id"),
      position: {
        latitude: position[0],
        longitude: position[1],
      }, 
      preferences: {
        title: 'My Mark',
        snippet: 'My Location',
      }
    });

//get the marker's ID
  console.log(JSON.parse(JSON.stringify(mymarker))['marker']['markerId']);

Regards, Mujie

bstrasburg commented 2 years ago

Im sorry, my issue is with @capacitor/google-maps. Do you know what the difference is between the 2? I might have to switch to the @capacitor-community/capacitor-googlemaps if I keep getting these errors.

mujie-dm commented 2 years ago

Im sorry, my issue is with @capacitor/google-maps. Do you know what the difference is between the 2? I might have to switch to the @capacitor-community/capacitor-googlemaps if I keep getting these errors.

Previously I also used @capacitor/google-maps, but after experiencing some problems, I tried @capacitor-community/capacitor-googlemaps. Maybe you can try it with a simple project first to try this plugin.

Regards, Mujie

tafelnl commented 2 years ago

Thanks @mujie-dm for jumping in and explaining that there is a difference between the two libraries. When I have some time on my hands I will write an explanation on the difference between the two.