0

My leaflet map shows grey tiles. I added the layer also. This is how it shows

<div class="col-md-5">
   <div id="mainMap" style="height: 400px"></div>
</div>

const mainMap = new L.map("mainMap", {
    doubleClickZoom: false,
    zoomControl: false,
}).setView([34.543896, 64.160652], 6);
const osm = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
        maxZoom: 6,
        attribution:
            '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
    });
    mainMap.addLayer(osm);

1 Answers1

0

Remember to include CSS files:

<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
   integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
   crossorigin=""
/>

This should work for you.

muszynov
  • 319
  • 5
  • 22