user1595929
user1595929

Reputation: 1372

Vue2Leaflet component does not display the map

I'm trying to use the Vue2Leaflet component (https://vuejsexamples.com/vue-2-components-for-leaflet-maps/) but I have hard time to make it works. I could not make this simple example work, with the html file :

<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>

and the js file :

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'});

I made a fiddle with this basic exemple : http://jsfiddle.net/rvxc2uLk/3. What am I missing ?

Upvotes: 0

Views: 505

Answers (1)

David
David

Reputation: 266

You forgot the "L" before .TileLayer also for .Marker.

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

Upvotes: 1

Related Questions