I'm trying to create a map with reac-leaflet in ionic but I'm not displaying it correctly, also following this link: Missing Leaflet Map Tiles when using react-leaflet
WINDOW RESIZING FIX IT. What am I doing wrong on first login?
On first access this is the map:
After resizing:
Here the code.
In index.html
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"/>
Home.tsx simplified.
import { Map, Marker, Popup, TileLayer } from 'react-leaflet';
function Home() {
return (
<IonPage>
<IonHeader>
<IonToolbar color="primary">
<IonTitle>Logged in ... </IonTitle>
</IonToolbar>
</IonHeader>
<IonContent>
<Map center={[45.24,8.55]} zoom={13}>
<TileLayer
attribution='&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<Marker position={[45.24,8.55]}>
<Popup>
A pretty CSS3 popup. <br /> Easily customizable.
</Popup>
</Marker>
</Map>
</IonContent>
</IonPage>
)
}
export default Home;
In css file.
.leaflet-container {
height: 100%;
width: 100%;
}
Thank you.