I'm trying to change the Leaflet default Icon; in my script I set

L.Icon.Default.prototype.options.iconUrl = 'Point.png';

The .png file is in the same folder than my script file but I get a broken image icon, the .png is not found.

How can I specify the right .png location ?

  • 2
    Use your browser's developer tools, network section, to check what URL is being requested. – IvanSanchez Apr 5 at 10:15
  • Browser expects Point.png to be in unpkg.com/leaflet@1.3.4/dist/images/Point.png – Hervé Apr 5 at 13:07
  • Note how the URL is relative to the leaflet.css file. Approaches include (a) specifying absolute URLs (b) hosting the Leaflet files yourself and provide URLs relative to those. – IvanSanchez Apr 5 at 13:19
  • I host the Leaflet folder, do you mean I must put the .png in the same folder than leaflet.css ? – Hervé Apr 5 at 14:32
  • You might be hosting it already, but something is pointing to unpkg.com/leaflet@1.3.4/dist . – IvanSanchez Apr 5 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.