html - ReactJs 中使用 ReactMapGL 的无响应页面布局
问题描述
我的页面中有一个 ReactMapGL 组件,它存储在页脚上方和导航栏下方。在我桌面的初始屏幕中,布局看起来不错,但是当我检查元素以缩小屏幕尺寸时,布局变得无响应。
到目前为止,这是我在这个特定页面上的代码:
export default function Map({posts}) {
const [viewport, setViewport] = useState({
latitude: 45.4211,
longitude: -75.6938,
width:"100vw",
height:"100vh",
zoom: 10,
});
const [selectedProperty, setSelectedProperty] = useState(null)
return (
<div>
<ReactMapGL {...viewport} mapboxApiAccessToken="//mykey"
mapStyle="mapbox://styles/jay/cks5xkaa892cp17o5hyxcuu0z"
onViewportChange={viewport => {
setViewport(viewport);
}}>
{
posts &&
posts.map((maps) => (
<Marker key={maps.id} latitude={maps.Latitude} longitude={maps.Longitude}>
<button className="marker-btn" onClick={e => {
e.preventDefault();
setSelectedProperty(maps);
}}>
<img src="placeholder.svg"/>
</button>
</Marker>
))}
{selectedProperty ? (
<Popup latitude={selectedProperty.Latitude} longitude={selectedProperty.Longitude}
onClose={() => {setSelectedProperty(null);}}>
<h1>{selectedProperty.Title}</h1>
</Popup>) : null}
</ReactMapGL>
</div>
);
}
对于导航栏和页脚,我从这里复制粘贴了 html 和 css 。
解决方案
推荐阅读
- r - 如何在自定义函数中参数化变异操作?
- python - 在 tkinter 中更改仅 askopenfilename 的图标,同时在 python 中隐藏主 Tk() 窗口
- java - 由 Spring-Boot 端点调用时,Java Jersey 端点获取空参数
- python - Kafka 获取对应消息 ID 的分区 ID
- java - 如何从自定义远程存储库添加库
- visual-studio - 命令行参数不会传递给 Docker 容器入口点
- python - 比较python中的两个正在运行的脚本
- node.js - 错误 cb.apply 不是 Node Express 项目中 [尝试安装软件包时] 的功能 --
- django - 如何在不从 Django 中的中间件引发异常的情况下向用户报告错误
- swiper - 使用缩略图和进度创建 swiper