Skip to content

vue 3 leaflet implementation #152

@ibrahim-developper

Description

@ibrahim-developper

These dependencies were not found:

  • leaflet in ./node_modules/@vue-leaflet/vue-leaflet/dist/vue-leaflet.esm.js
  • leaflet/dist/images/marker-icon-2x.png in ./node_modules/@vue-leaflet/vue-leaflet/dist/vue-leaflet.esm.js
  • leaflet/dist/images/marker-icon.png in ./node_modules/@vue-leaflet/vue-leaflet/dist/vue-leaflet.esm.js
  • leaflet/dist/images/marker-shadow.png in ./node_modules/@vue-leaflet/vue-leaflet/dist/vue-leaflet.esm.js
  • leaflet/dist/leaflet-src.esm in ./node_modules/@vue-leaflet/vue-leaflet/dist/vue-leaflet.esm.js, ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader-v16/dist??ref--0-1!./src/App.vue?vue&type=script&lang=js
  • leaflet/dist/leaflet.css in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader-v16/dist??ref--0-1!./src/App.vue?vue&type=script&lang=js

To install them, you can run: npm install --save leaflet leaflet/dist/images/marker-icon-2x.png leaflet/dist/images/marker-icon.png leaflet/dist/images/marker-shadow.png leaflet/dist/leaflet-src.esm leaflet/dist/leaflet.css

i'm user the same example in documentation

import "leaflet/dist/leaflet.css"
import { LMap, LGeoJson } from "@vue-leaflet/vue-leaflet";

export default {
name: 'App',
components: {
LMap,
LGeoJson,
},
data() {
return {
geojson: {
type: "FeatureCollection",
features: [
// ...
],
},
geojsonOptions: {
// Options that don't rely on Leaflet methods.
},
};
},
async beforeMount() {
// HERE is where to load Leaflet components!
const { circleMarker } = await import("leaflet/dist/leaflet-src.esm");

// And now the Leaflet circleMarker function can be used by the options:
this.geojsonOptions.pointToLayer = (feature, latLng) =>
  circleMarker(latLng, { radius: 8 });
this.mapIsReady = true;

},

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions