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.

Autodetection of L.Icon.Default.imagePath, getScript() inclusion

See original GitHub issue

The method used to auto detect the correct path to the default marker and shadow images causes problems under two circumstances:

  1. The search regex /\/?leaflet[\-\._]?([\w\-\._]*)\.js\??/ also matches unintended similar files such as leafletFooBar.js, giving the markers the wrong relative path. Since only leaflet.js and leaflet-src.js need to be matched, /\/?leaflet(-src)?\.js\??/ might work instead.

  2. The nature of the method being used (search the page for the correct script tag) defeats the use of getScript() to include leaflet.js from another file, as in this case the desired script tag is not present in the page.

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

14reactions
mournercommented, Aug 14, 2012
L.Icon.Default.imagePath = 'path-to-your-leaflet-images-folder';
// your other Leaflet code
7reactions
vinyllcommented, Feb 13, 2016

Same issue here after moving <leaflet-map> from the index file into a component (using Polymer here).

I had to set the path like this:

ready() {
    L.Icon.Default.imagePath = '../bower_components/leaflet/dist/images/'
}

And the map would display the icons again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change the default icon pin on leaflet directive?
From the Leaflet documentation, see Icon.Default : In order to change the default icon, just change the properties of L.Icon.Default.prototype.options ...
Read more >
"Error: Couldn't autodetect L.Icon.Default.imagePath, set it ...
When researching my issue I came across a related libraries issue. It seemed to suggest that using the inline code method is not...
Read more >
L.Icon - WRLD3D
Icon. Represents an icon to provide when creating a marker. Usage example. var myIcon = L.icon({ iconUrl: 'my-icon.png', iconSize: [38, 95], iconAnchor: [22 ......
Read more >
Untitled
makeArray( selector, this ); }, // Start with an empty selector selector: "", // The default length of a jQuery object is 0...
Read more >
https://ora.ox.ac.uk/objects/uuid:968655ac-e8ec-4b...
toLowerCase().split(ee),a=0,l=s.length;a<l;a++)i=s[a],o=/^\+/.test(i) ... imagePath;if(!n)throw new Error("Couldn't autodetect L.Icon.Default.
Read more >

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