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
272 stars 54 forks source link

findPlaceFromQuery is not a function #89

Closed lightman0215 closed 2 years ago

lightman0215 commented 2 years ago

HTML Code `<GoogleMap ref="dianzhuangMap" id="Mapdian" @click="getStations" :language="$i18n.locale" :key="dataForm.name" api-key="AIzaSyAU9sDf9Nc1IJjCKqEfcAM-obouMK_eodY" style="width: 100%; height: 700px" :center="center" :zoom="10">

</GoogleMap>`

Vue: const service = this.$refs.dianzhuangMap.api.places.PlacesService; service.findPlaceFromQuery(request, (results: any, status: any) => { console.log(results); });

how can i fix it?

HusamElbashir commented 2 years ago

Hi @lightman0215

I think you'll first need to instantiate PlacesService: https://developers.google.com/maps/documentation/javascript/reference/places-service#PlacesService.constructor

Something like this:

const service = new this.$refs.dianzhuangMap.api.places.PlacesService(this.$refs.dianzhuangMap.map)