The marker icon is not displayed in a vue.js webpack template
See original GitHub issueDescription
The marker icon can’t be loaded properly when using v-marker
as shown in the image below (in Actual results). As you can see the marker img
element is on the DOM but the src
url is not pointing to the correct image.
Steps to Reproduce
here the code I am using, it is almost the same as provided in the README
import vue2Leaflet from 'vue2-leaflet'
export default {
components: {
vMap: vue2Leaflet.Map,
vTilelayer: vue2Leaflet.TileLayer,
vMarker: vue2Leaflet.Marker
}
}
<!-- show map -->
<div style="height: 300px;>
<v-map :zoom="12" :center="[location.lat, location.lon]">
<v-tilelayer url="http://{s}.tile.osm.org/{z}/{x}/{y}.png"></v-tilelayer>
<v-marker :lat-lng="[location.lat, location.lon]"></v-marker>
</v-map>
</div>
Expected Results
The marker image get displayed properly
Actual Results
The marker image is on the DOM but is not displayed properly
Browsers Affected
I tested it just on these browsers
- Chrome
- Firefox
Versions
- Leaflet: v1.2.0
- Vue: v2.3.4
- Vue2Leaflet: v0.0.57
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
Vue.js: Leaflet-Marker is not visible - Stack Overflow
Now I solved it by importing the png directly in the component. In case it could help. Map.vue component. template <l-marker> <l-icon :icon-url= ......
Read more >Working with Webpack | Vue CLI
Some webpack options are set based on values in vue.config.js and should not be mutated directly. For example, instead of modifying ...
Read more >FAQ | Vue Leaflet
In most cases, though, it is Webpack messing with Leaflet marker icons' paths, resulting in warnings or even errors. You can alleviate that...
Read more >Vue2Leaflet is not placing custom Icon in the map-Vue.js
Coding example for the question Vue2Leaflet is not placing custom Icon in the map-Vue.js.
Read more >Default Leaflet icon is not showing - GIS Stack Exchange
marker ([50,10], {icon: myIcon}).addTo(this.map);. leaflet · javascript.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Issue is known. Add the following to main.js
That worked for me 😃
@simenJohnsen thanks, I was struggling to find the solution.
Is there any explanation of a cause of the problem?