简体   繁体   中英

react-leaflet / there is problem with Mapcontainer

the component render well but It doesn't display so I change some css property from Inspect. I put map container in part of my page in div - but map work differently from div. this is my code.

<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>

also I put main css of leaflet on index.html

I don't what am I doing but I think there is problem with css. 在此处输入图像描述

the main property that you should assign is height - I should just set height in inline css proerty to my component,

react-leaflet you have to consider this rule

<MapContainer style={{width:'90%',height:'99%'}} center={[51.505, -0.09]} zoom={13} scrollWheelZoom={true}>

ta-daaa!!! map work very well

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM