0

I am using React Leaflet. React and everything is working fine, but when I try to use React lazy loading the map just not render or render a small square as shown below. It is just a small box.

enter image description here

<MapContainer center={[selectedLat, selectedLong]} zoom={zoom}>
 <ChangeView center={[selectedLat, selectedLong]} zoom={zoom} />
  <TileLayer attribution='&copy; <a 
   href="http://osm.org/copyright">OpenStreetMap</a> contributors'  
   url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
</MapContainer>

Also, I added the CSS in index.html:

<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"
  integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
  crossorigin="" />
Zsolt Meszaros
  • 21,961
  • 19
  • 54
  • 57

0 Answers0