Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
Why is my icon showing up as an empty square with Leaflet JS?

I'm trying to make my point marker have a picture icon, but for some reason, it's showing up on my map like this:

I've looked at the documentation on leaflet's website and what not but have had no luck. It's probably something pretty simple that I'm missing or brain farting on haha. Any help is much appreciated. Let me know what other code you might need to address the problem. TIA!

Here's my script

<script>
  //create variable to hold the map element, give initial settings to map
  var map = L.map("map", {
    center: [38.1, -98.583333],
    zoom: 4,
  });
  //add OSM tile layer to map element
  L.tileLayer(
    "https://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}{r}.png",
    {
      attribution:
        '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors &copy; <a href="https://carto.com/attributions">CARTO</a>',
      subdomains: "abcd",
      maxZoom: 19,
    }
  ).addTo(map);

  var logo = L.icon({
    iconUrl: "imgs/patrickLogo.png",
    iconSize: [20, 20],
  });

  L.marker([40.308746567390294, -105.08229135535235], { icon: logo })
    .addTo(map)
    .bindPopup("Berthoud, CO");
</script>

UPDATE: It's a 404 error. What does that mean and how can I fix it?

RESOLVED: changed my image path to an absolute path and it worked! Thanks, y'all.

var logo = L.icon({
    iconUrl:
      "https://d2q79iu7y748jz.cloudfront.net/s/_squarelogo/8ec294c2f144d43bf5d7ec5f4f96d0c9",
    iconSize: [20, 20],
  });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!