VueJS + Quasar Framework + Google Maps JS API - PullRequest
0 голосов
/ 06 декабря 2018

Не могли бы вы помочь мне импортировать Google Maps API в мое приложение VUE, созданное с помощью Quasar Framework?

Я установил google-maps

Я следовалинструкции здесь и я создаю файл gmapApi.js

import GoogleMapsLoader from 'google-maps'
// leave the export, even if you don't use it
export default ({ app, router, Vue }) => {
   Vue.prototype.$gmaps = GoogleMapsLoader
   Vue.prototype.$gmaps.KEY = 'MY-KEY'
   Vue.prototype.$gmaps.LIBRARIES = ['places']
}

Затем я добавил gmapApi в свой quasar.conf.js под плагинами

// app plugins (/src/plugins)
plugins: [
  'gmapApi'
]

Тогда какссылаться на gmap в компоненте Vue?скажем, я хочу изменить геолокацию позицию

Я пытался

var geocoder = new this.$gmaps.maps.Geocoder()

Но я получаю сообщение об ошибке, что карты не определены.

Что такоеЯ здесь скучаю?Я даже на правильном пути?

1 Ответ

0 голосов
/ 06 декабря 2018

Неважно, нашел его

   this.$gmaps.load(function (google) {
      let geocoder = new google.maps.Geocoder()
      let point = new google.maps.LatLng(position.coords.latitude, position.coords.longitude)
      console.log(point)
      geocoder.geocode({'latLng': point}, function (locations, status) {
        console.log(status + ' ' + locations)
      })
    })
...