Have the problem with map: not fully rendering Map.
My application work using vuejs-templates and vue-loader. And I found some problem with webpack and Vue2Leaflet, after that I add to my main.js next lines:
import L from 'leaflet';
delete L.Icon.Default.prototype._getIconUrl;
L.Icon.Default.mergeOptions({
iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'),
iconUrl: require('leaflet/dist/images/marker-icon.png'),
shadowUrl: require('leaflet/dist/images/marker-shadow.png')
});
And after that, I have the same issue.
<template>
<div>
<l-map style="height: 90%" :zoom="zoom" :center="center">
<l-tile-layer :url="url" :attribution="attribution"></l-tile-layer>
<l-marker :lat-lng="marker"></l-marker>
</l-map>
</div>
</template>
<script>
import { LMap, LTileLayer, LMarker } from 'vue2-leaflet';
export default {
name: 'example',
components: {
LMap,
LTileLayer,
LMarker
},
data () {
return {
zoom:13,
center: L.latLng(47.413220, -1.219482),
url:'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
attribution:'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
marker: L.latLng(47.413220, -1.219482),
}
},
methods: {
mounted() {
setTimeout(function() { window.dispatchEvent(new Event('resize')) }, 250);
}
}
}
</script>

How it fix? @KoRiGaN do you have any ideas?
Hi @ximet,
You need to import the css from leaflet into your project.
import "leaflet/dist/leaflet.css"
Hope this helps,
Micka毛l
@KoRiGaN I added this styles, and have the same issue
Hi @ximet,
Do you have a project where I can see/reproduce this issue?
Very hard to tell what's going wrong here without reproducing it.
@ximet I added
import "leaflet/dist/leaflet.css";
to my main.js ,then solved it.
Closing this issue as no comment for 3 weeks,
@ximet if you still have this issue feel free to reopen it.
Micka
I have the exact same issue. I didnt have an issue until I did a big update since christmas. It might have been the new 1.0.1 version. Same issue in 1.0.1 and 1.0.1.
Some tiles show and are in different orders. Tried debugging it but does not show up any errors.
When I include the css file then now tiles show. There might be a conflict some where.
import "leaflet/dist/leaflet.css";
Vue2Leaflet: 1.0.1 and Leaflet.js: 1.3.1. This is a basic project with just vue2 leaflet added.
https://github.com/martinnaughton/leafletbasic
I am I missing some in the setup?
Same here as @martinnaughton above.
I found that adding
@import 'http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.css';
instead
@import 'leaflet/dist/leaflet.css
renders the map correctly.
TL;DR: height of map must be in pixels,em or vh not in %
I found the solution.
First add to main.js:
import L from 'leaflet'
import 'leaflet/dist/leaflet.css'
delete L.Icon.Default.prototype._getIconUrl
L.Icon.Default.mergeOptions({
iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'),
iconUrl: require('leaflet/dist/images/marker-icon.png'),
shadowUrl: require('leaflet/dist/images/marker-shadow.png')
})
then the thing is that height of map must be in pixels,em or vh.
<l-map ref="map"
:zoom="zoom"
:center="center"
style="height:200px;">
<l-tile-layer :url="url"
:attribution="attribution"></l-tile-layer>
<l-marker :lat-lng="marker"></l-marker>
</l-map>
I can confirm that fixed the issue when doing both changes.
Not sure how the example works then with version 1.0.2?
https://github.com/KoRiGaN/Vue2Leaflet/blob/master/examples/src/components/Simple.vue
Does anyone by chance know how to get the markers working when using codesandbox.io ? The 'require' statements to patch things up are resolving to the content of the full images..
TypeError
Failed to execute 'fetch' on 'Window': Failed to parse URL from 锟絇NG (png data here)
In my case fix this:
@import 'leaflet/dist/leaflet.css
and add this to component
mounted() {
this.$refs.map.mapObject._onResize();
}
I made it work by doing these two changes -
1) added style="height:800px" in
2) added "import 'leaflet/dist/leaflet.css" in component.
Hey, I am still getting this same issue even after importing CSS. I am trying the code from here: https://github.com/KoRiGaN/Vue2Leaflet/blob/master/examples/src/components/Simple.vue. How can I fix this?

This is usually the result of missing or not properly imported CSS. How are you importing the CSS? Can you provide us with code or even better a code pen? @RamizSami
Hey @lordfuoco this is my vue file:
https://dpaste.de/YNAd
@RamizSami Hi!
So
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
Your style is scoped, your import is going to be scoped, and since leaflet is not part of your component the css is not going to reach it.
Solution: if is okay remove scoped from the style block.
If is not okay import the css in the js -> import "leaflet/dist/leaflet.css";
Hey thanks! It worked after removing 'scoped'
Closing this since is solved
For me it was a problem of height of the map. I put height:inherit and it works
leaflet inside vuetify component
<l-map ref="map" v-resize="onResize" :zoom="zoom" :center="center">
<l-tile-layer :url="url"></l-tile-layer>
<l-marker :lat-lng="center"></l-marker>
</l-map>
methods: {
onResize() {
this.$refs.map[0].mapObject._onResize();
},
}
problem solved for me
Removing any height and width expressed in percentage worked for me too.
I talked too early: sometimes it works, sometimes it doesn't.
I can't make it stable one way or the other.
i noticed the Vue2Leaflet doesnt render well with Tailwindcss in the project
Anyone else having this problem with vuetify?
Most helpful comment
@ximet I added
import "leaflet/dist/leaflet.css";to my main.js ,then solved it.