javascript - 谷歌地图未在 vue.js 中显示

标签 javascript google-maps cordova vue.js monaca

我使用 Monaca、Cordova 和 onsenUI 构建了一个基于 Vue.js 的应用程序。我想在我的页面中使用 Google map 显示我的位置。为了实现这一点,我使用了一个 npmvue2-google-maps 但它没有显示任何内容。

我使用的代码来自软件包的官方文档。它们如下所示:

    <template>
      <v-ons-page>
        <custom-toolbar>Page 1</custom-toolbar>
        <div>
       <gmap-map
        :center="center"
        :zoom="7"
        style="width: 500px; height: 300px"
       >
        <gmap-marker
          :key="index"
          v-for="(m, index) in markers"
          :position="m.position"
          :clickable="true"
          :draggable="true"
          @click="center=m.position"
        ></gmap-marker>
      </gmap-map>
      </div>
      </v-ons-page>
    </template>
    <script>
    import * as VueGoogleMaps from 'vue2-google-maps';
      import Vue from 'vue';

      Vue.use(VueGoogleMaps, {
        load: {
          key: 'AIzaSyDX3SEHwFUY-k_Jp7YMp0-uTvo7up-paXM',
          v: '3.26',
          // libraries: 'places', //// If you need to use place input
        }
      });

      export default {
        data () {
          return {
            center: {lat: 10.0, lng: 10.0},
            markers: [{
              position: {lat: 10.0, lng: 10.0}
            }, {
              position: {lat: 11.0, lng: 11.0}
            }]
          }
        },


         props: ['pageStack'],
         components: { customToolbar }

     };
    </script>

最佳答案

对于遇到此问题的任何人,请查看此 issue .基本上,您这边没有任何改变,只需设置 map 元素的高度即可。

关于javascript - 谷歌地图未在 vue.js 中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46138047/

相关文章:

css - 背景固定phonegap

javascript - 来自已解析 Promise 的数据未在组件 View 中正确加载(Angular2、JavaScript)

javascript - Jquery如何在更改并加载图像src后引起 Action

javascript - jQuery 函数 : pass callback functions as optional arguments to another function

google-maps - 谷歌地理编码 API 为网络标准化地址返回 ZERO_RESULTS

javascript - Android + PhoneGap + jQuery Mobile 上的水平滚动图像

javascript - 当元素位于视口(viewport)中时添加类的问题

javascript - 使用 Google map 绘制半径内的点

javascript - 谷歌地图 API v3 : Click events not triggered in firefox for custom marker

cordova - 错误 - 不支持使用 "requireCordovaModule"加载非 Cordova 模块 "q"