vue-google-maps icon indicating copy to clipboard operation
vue-google-maps copied to clipboard

loading not complete at loaded event trigger

Open rmNyro opened this issue 7 years ago • 7 comments

Hi,

Plain and simple:

import { loaded } from '~/node_modules/vue2-google-maps/src/main'

export default {
    created() {
        loaded.then(() => {
            console.log(this.$refs.gmap.$mapObject) // undefined?!
        }
    },
}

I may be wrong but it seems wrong to me to not be able to access the object after loaded event triggered. : / I don't have any time to try to fix it, sorry.

Best regards.

rmNyro avatar Jan 19 '18 15:01 rmNyro

If you want the mapObject, you need $mapPromise.then(() =>{... CODE HERE...})

This is because loaded only loads the Google Maps API, but the maps have not been initialized.

On 19 Jan 2018 23:59, "Remy RUIZ" [email protected] wrote:

Hi,

Plain and simple:

import { loaded } from '~/node_modules/vue2-google-maps/src/main' export default { created() { loaded.then(() => { console.log(this.$refs.gmap.$mapObject) // undefined?! } }, }

I may be wrong but it seems wrong to me to not be able to access the object after loaded event triggered. : / I don't have any time to try to fix it, sorry.

Best regards.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xkjyeah/vue-google-maps/issues/294, or mute the thread https://github.com/notifications/unsubscribe-auth/ACiTR64vwcJkmx-bELRIXszfoXw2DjLtks5tMLvMgaJpZM4Rkrg7 .

xkjyeah avatar Jan 21 '18 07:01 xkjyeah

Okay got it. Maybe include this in the doc, I don't know how to get the info otherwise. I wish I had more time to help you with. Thanks! :)

rmNyro avatar Jan 29 '18 09:01 rmNyro

Hey, I closed this a bit fast (had some other things to do).

Where is the $mapPromise object? I thought it was in the map as well as $mapObject but it's not. So I guess it's somewhere else?

rmNyro avatar Feb 01 '18 15:02 rmNyro

use $mapCreated.

on4r avatar Mar 01 '18 10:03 on4r

None of these options appear to work in a child component. I'm attempting to use the method map.getProjection() inside the handler for the this.$mapPromise.then(map => { ... }) and, somehow, even if map is defined, it sometimes gives me map.getProjection() is not a function which is a very strange error that I imagine is related to whatever wrapping process is done to the raw map instance.

dkushner avatar Aug 23 '18 05:08 dkushner

@dkushner Same issue for me.

vinczebalazs avatar Sep 19 '18 11:09 vinczebalazs

None of these options appear to work in a child component. I'm attempting to use the method map.getProjection() inside the handler for the this.$mapPromise.then(map => { ... }) and, somehow, even if map is defined, it sometimes gives me map.getProjection() is not a function which is a very strange error that I imagine is related to whatever wrapping process is done to the raw map instance.

Is there a solution for this in 2022?

r1987 avatar Feb 22 '22 08:02 r1987