Нужна помощь, чтобы соответствовать переменным правильно - PullRequest
0 голосов
/ 10 ноября 2019

vue2-google-maps json, как отформатировать входные данные

лат, lon из db как десятичные, отправить в формате json

computed: mapState({
 company: state => state.company.company
})

{{company.latitude}} 

<gmap-map :center="{ lat: 50.0200271000, lng: 8.8775603000 }"
works but I cant get it working like that:

<gmap-map :center="{ lat: company.latitude, lng: company.longitude }"
<gmap-map :center="{ lat: 'company.latitude', lng: 'company.longitude' }"

How to do it right? Thanks for support.

1 Ответ

0 голосов
/ 11 ноября 2019

Вы можете использовать store вот так.

computed: {
   latitude() {
       return this.$store.state.company.latitude;
   },
   longitude() {
       return this.$store.state.company.longitude;
   }
}

// Template
<gmap-map :center="{ lat: latitude, lng: longitude }" />
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...