jperelli / vue2-leaflet-markercluster

markercluster plugin extension for vue2-leaflet package
MIT License
132 stars 55 forks source link

Unknown custom element #36

Closed alemangui closed 4 years ago

alemangui commented 4 years ago

Hello @jperelli , I have an issue in which I can't figure out how to get the Vue2LeafletMarkerCluster component to work. I have the map and the markers, but not the marker cluster.

[Vue warn]: Unknown custom element: <l-marker-cluster> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <Map> at src/views/Map.vue
       <VContent>
         <VApp>
           <App> at src/App.vue
             <Root>

I am importing the component:

import { Vue2LeafletMarkerCluster } from "vue2-leaflet-markercluster"
import { LMap, LGeoJson, LMarker, LPopup } from "vue2-leaflet"
import { latLng } from "leaflet"

And registering it inside mine with the alias 'l-marker-cluster':

components: {
    'l-map': LMap,
    'l-marker': LMarker,
    'l-marker-cluster': Vue2LeafletMarkerCluster,
    'l-geo-json': LGeoJson,
    'l-popup': LPopup,
},

Which I use in my template:

<l-map :options="{ zoomSnap: 0.2, maxZoom: 18 }" :center="center" :zoom="5.6" style="height: 520px;">
  <l-geo-json :geojson="geojson" :options="options" :options-style="styleOptions" />
  <l-marker-cluster>
    <l-marker v-for="(c, index) in cases" :key="index" :lat-lng="c.latlng">
      <l-popup :content="c.tooltipContent"></l-popup>
    </l-marker>
  </l-marker-cluster>
</l-map>

All components work and are displayed except the marker-cluster.

I have:

Thanks!

gsusanj commented 4 years ago

Try to use import without {}, like this:

import Vue2LeafletMarkerCluster from 'vue2-leaflet-markercluster'

alemangui commented 4 years ago

Omg :man_facepalming: , thanks @Sonicelo