【问题标题】:Vue2Leaflet component does not display the mapVue2Leaflet 组件不显示地图
【发布时间】:2019-12-14 00:34:41
【问题描述】:

我正在尝试使用 Vue2Leaflet 组件 (https://vuejsexamples.com/vue-2-components-for-leaflet-maps/),但我很难让它工作。我无法使用 html 文件使这个简单的示例工作:

<html>
  <head>
    <link rel="stylesheet" type="text/css" href="https://unpkg.com/leaflet/dist/leaflet.css" />
  </head>
  <body>

    <div id="app" style="height: 400px">
      <v-map :zoom=13 :center="[47.413220, -1.219482]">
        <v-tilelayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"></v-tilelayer>
        <v-marker :lat-lng="[47.413220, -1.219482]"></v-marker>
      </v-map>
    </div>

    <script src="https://unpkg.com/vue"></script>
    <script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
    <script src="https://unpkg.com/vue2-leaflet"></script>
  </body>
</html>

还有js文件:

Vue.component('v-map', window.Vue2Leaflet.LMap)
Vue.component('v-tilelayer', window.Vue2Leaflet.TileLayer)
Vue.component('v-marker', window.Vue2Leaflet.Marker)
new Vue({ el: '#app'});

我对这个基本示例做了一个小技巧:http://jsfiddle.net/rvxc2uLk/3。 我错过了什么?

【问题讨论】:

    标签: vue.js leaflet


    【解决方案1】:

    .TileLayer 之前的“L”也忘记了.Marker

    Vue.component('v-map', window.Vue2Leaflet.LMap)
    Vue.component('v-tilelayer', window.Vue2Leaflet.LTileLayer)
    Vue.component('v-marker', window.Vue2Leaflet.LMarker)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-09
      • 1970-01-01
      • 2021-05-28
      • 1970-01-01
      • 1970-01-01
      • 2021-04-25
      • 2012-11-30
      相关资源
      最近更新 更多