[英]react-leaflet / there is problem with Mapcontainer
組件渲染得很好,但它沒有顯示,所以我從 Inspect 更改了一些 css 屬性。 我將 map 容器放在 div 中的部分頁面中 - 但 map 的工作方式與 div 不同。 這是我的代碼。
<div className={style.map_container}> //this my container I wrote it
<MapContainer style={{height:'80px',width:'80'}} center={[51.505, -0.09]} zoom={13} scrollWheelZoom={false}>
<TileLayer attribution='contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"/>
<Marker position={[51.505, -0.09]}>
<Popup>
A pretty CSS3 popup. <br /> Easily customizable.
</Popup>
</Marker>
</MapContainer>
</div>
我還將 leaflet 的主要 css 放在 index.html
您應該分配的主要屬性是高度 - 我應該在我的組件的內聯 css 屬性中設置高度,
react-leaflet你必須考慮這個規則
<MapContainer style={{width:'90%',height:'99%'}} center={[51.505, -0.09]} zoom={13} scrollWheelZoom={true}>
噠噠噠!!! map 工作得很好
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.