question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Defaul Marker Icon loaded though not used

See original GitHub issue

Steps to Reproduce

I’m only using L.DivIcon in my project and not any IconUrl at all.

<l-marker v-for="location in locations" :key="location.id" :lat-lng="location.coordinates">   
  <l-icon class-name="marker-div">
    <div class="marker-icon>
        ***marker html code***
    </div>
 </l-icon>
</l-marker>

Expected Results

marker-icon.png and marker-shadow.png not getting loaded in browser and “marker icon fix” not necessary.

Actual Results

marker-icon.png and marker-shadow.png are still getting loaded and need to be fixed by

import { Icon } from 'leaflet';
delete Icon.Default.prototype._getIconUrl;
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'),
});

which increased the size of the bundle and all browsers download unnecessarily the icons.

Browsers Affected

  • [ x ] Chrome
  • [ x ] Firefox
  • [ x ] Edge
  • [ x ] Safari 9
  • [ x ] Safari 8
  • [ x ] IE 11

Versions

  • Leaflet: v1.6.0
  • Vue: v2.6.11
  • Vue2Leaflet: v2.5.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
vchrisbcommented, Jun 17, 2020

@fbnlsr this is a different issue directly related to leaflet with webpack. At top of the FAQ are a few solutions linked. https://vue2-leaflet.netlify.app/faq/

import { Icon } from 'leaflet';
delete Icon.Default.prototype._getIconUrl;
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'),
});

can be used to fix it, but this issue here is regarding using no default marker at all.

1reaction
DonNicoJscommented, Jun 17, 2020

@vchrisb Thanks this actually helps! I will try to create a repro case and investigate

Read more comments on GitHub >

github_iconTop Results From Across the Web

Marker icon always default - Stack Overflow
I can't seem to get my custom icon to display though, i always get the blue default. First I create the markerClusterGroup
Read more >
Default Leaflet icon is not showing - GIS Stack Exchange
The default icon is defined as L.Icon.Default . To use it do not pass icon to the marker. So the code should be....
Read more >
Markers | Maps SDK for iOS - Google Developers
Markers indicate single locations on the map. By default, markers use a standard icon that has the common Google Maps look and feel....
Read more >
React Google Maps Api Style Guide
LoadScript - Loads the Google Maps API script; GoogleMap - The map component inside ... The click event is not fired if a...
Read more >
Add markers | Help - Mapbox docs
No default marker icons in Mapbox Studio. If you are adding markers for custom data in Mapbox Studio, we recommend that you add...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found