如何使用 vue2-google-maps 显示谷歌地图

Posted

技术标签:

【中文标题】如何使用 vue2-google-maps 显示谷歌地图【英文标题】:How to display Google Maps with vue2-google-maps 【发布时间】:2020-02-29 13:50:03 【问题描述】:

我想在我的应用程序中使用 vue2-google-maps,但地图没有显示。我仔细关注了documentation 的使用方法,但我看到的唯一内容是空白页而不是谷歌地图。控制台中没有错误。

这是我的代码:

<template>
  <gmap-map :center="
      lat: 47.2736,
      lng: 16.0843
    "></gmap-map>
</template>

<script>
export default 
  data: () => 
    return 
  
</script>

如您所见,这是最简单的实现,但我看到的只是一个空白页。我检查了页面,我可以看到 vue-map 容器和所有元素,但地图没有显示在应用程序中。

【问题讨论】:

【参考方案1】:

看来我只需要添加 zoom 属性:

<template>
  <gmap-map :center="
      lat: 47.2736,
      lng: 16.0843
    " 
    :zoom="7"></gmap-map>
</template>

【讨论】:

以上是关于如何使用 vue2-google-maps 显示谷歌地图的主要内容,如果未能解决你的问题,请参考以下文章