Google maps quasar vue问题中Google自动填充无地图地址
我用的是类星体框架。 和VueGmaps包,用于自动填充地址,我使用它安装它 npm安装vue GMAP——保存Google maps quasar vue问题中Google自动填充无地图地址,google-maps,vue.js,google-api,autocomplete,quasar,Google Maps,Vue.js,Google Api,Autocomplete,Quasar,我用的是类星体框架。 和VueGmaps包,用于自动填充地址,我使用它安装它 npm安装vue GMAP——保存 <script> import Vue from "vue"; import VueGmaps from 'vue-gmaps' mounted() { this.autocomplete = new google.maps.places.Autocomplete( (this.$refs.autocomplete),
<script>
import Vue from "vue";
import VueGmaps from 'vue-gmaps'
mounted() {
this.autocomplete = new google.maps.places.Autocomplete(
(this.$refs.autocomplete),
{
type: ['geocode'],
componentRestrictions: { country: 'NZ' }
}
)
this.autocomplete.addListener('changed_place',()=>{
let place = this.autocomplete.getPlace()
let ac = place.address_components
let city = ac
this.city = city
this.cities.push(ac[0]['short_name'].concat(', ',ac[2]['short_name']))
console.log(this.city);
})
},
</script>
<teamplate>
<q-input
ref="autocomplete"
v-model="user.address"
filled
label="Physical Address"
hint="Your permanent address"
:rules="[val => !!val || 'This field is required.']"
/>
</template>
从“Vue”导入Vue;
从“vue gmaps”导入VueMaps
安装的(){
this.autocomplete=new google.maps.places.autocomplete(
(此.$refs.autocomplete),
{
类型:['geocode'],
组件限制:{country:'NZ'}
}
)
this.autocomplete.addListener('changed_place',()=>{
让place=this.autocomplete.getPlace()
设ac=place.address\u组件
让城市=ac
这个城市
this.cities.push(ac[0]['short_name'].concat(',',ac[2]['short_name']))
console.log(this.city);
})
},
我发现控制台中没有定义google。请查看下面的截图
当任何人在文本字段中键入任何内容时,我想让它给出地址的建议&从地址中选择城市、州、街道
不显示地图
有人能帮我吗
谢谢我删除了vue google autocomplete软件包 我发现我给出的是引用而不是id,我想google map api只适用于id属性 这是一个在不使用任何软件包的情况下对我有效的解决方案 它可能会帮助一些人。 并在安装
mounted() {
this.autocomplete = new google.maps.places.Autocomplete(
// (this.$refs.autocomplete),
(document.getElementById(“address”)),
{types: [‘geocode’]}
);
this.autocomplete.addListener(‘place_changed’, () => {
let place = this.autocomplete.getPlace();
let ac = place.address_components;
console.log(ac);
}
});