inocan-group / vue3-google-map

A set of composable components for easy use of Google Maps in your Vue 3 projects.
https://vue3-google-map.com
MIT License
280 stars 57 forks source link

googlemap api #26

Closed reslear closed 2 years ago

reslear commented 3 years ago

i found provide https://github.com/inocan-group/vue3-google-map/blob/9ef51c45b97ac3c2d9bd72f91aed90f170a1505a/src/components/GoogleMap.vue#L79

how to inject api on my components googlemaps api aka window.google GmapApi alternate https://github.com/xkjyeah/vue-google-maps/blob/vue2/src/main.js

or only use ref solution https://vue3-google-map.netlify.app/advanced-usage/ ?

HusamElbashir commented 3 years ago

You could use what you refer to as the ref solution in https://vue3-google-map.netlify.app/advanced-usage/ if you just need access to the api. We currently don't expose the api and map symbols, but it might be useful if we want to allow people to write their own custom components that add additional features. Something to think about.

yankeeinlondon commented 3 years ago

Sorry i'm reading this and not sure what the feature request is here. Can someone please elucidate this?

reslear commented 3 years ago

@ksnyde global api provide google api for use google maps api without refs in composable solution and component without maps, for example future place autocomplete

ps. place autocomplete components planned?

yankeeinlondon commented 3 years ago

@reslear can you give me a code example? Feel free to use a syntax you want rather than one that exists if that's needed but bear in mind our intention with the google API exposed by @googlemaps/js-api-loader is to allow you to do whatever you like with it directly. It is not our concern and our ambition is to be "out of the way" for this.

jrspitz commented 2 years ago

I've got an single page app that displays a map on some routes, and on other routes it uses the google maps api without a map (places autocomplete, geocoding).

Ideally, I'd like to initialize the api loader once, and pass around the instance to components as needed.

Would it be possible to pass the loader (or promise) to the GoogleMap component as a prop instead of it creating it's own from the api key?

HusamElbashir commented 2 years ago

Would it be possible to pass the loader (or promise) to the GoogleMap component as a prop instead of it creating it's own from the api key?

That shouldn't be hard to implement. I'll take a stab at it in the coming days.

HusamElbashir commented 2 years ago

@jrspitz Added this in v0.13.0. You can now pass a promise through the apiPromise prop which should resolve to the global google object. Example: https://stackblitz.com/edit/vitejs-vite-mgwr2y?file=src/components/HelloWorld.vue