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

154
Views
The leaflet is not displayed

I am new to JavaScript. The leaflet on the page doesn't display the map until I change the .leaflet-container property { overflow: ;}, you can see it in image2. How can I fix this? Thank you! CSS

<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"  />
<style>
    body {
        padding: 0;
        margin: 0;
    }
    html, body, #map {
        height: 100%;
        width: 100%;
    }

HTML

<div id="map"></div>

JS

</body>
    <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
    <script>
        var map = L.map.invalidateSize();
        L.tileLayer(
            'https://api.maptiler.com/maps/streets/256/{z}/{x}/{y}.png?key=ekfefkerdkdfk2', 
            {attribution: '<a href="https://www.maptiler.com/copyright/" target="_blank">&copy; MapTiler</a> <a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap contributors</a>'}
        ).addTo(map);
    </script>

image2 image1

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Replace var map = L.map.invalidateSize(); with

var map = L.map('map', {
    center: [51.505, -0.09],
    zoom: 13
});

If it still not work check if you overwrite div in some of your CSS classes. Else create a sample on https://leafletjs.com/edit

about 4 years ago · Juan Pablo Isaza Report
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!