小编Dmi*_*riy的帖子

使图像叠加的地图视图适合容器传单的大小

我正在使用 React Leaflet 创建自定义地图。

当前正在渲染卡片(图像叠加),但它不会填充放置卡片的容器。

容器的大小是严格设置的,我希望地图尽可能填充容器。所有使用 CSS 调整大小的尝试都失败了。

实例: https: //codesandbox.io/s/dark-worker-8qbzfr

我的代码:

import "./styles.css";
import { MapContainer, ImageOverlay } from "react-leaflet";
import "leaflet/dist/leaflet.css";

const M = ({ width, height, zoom, center }) => {
  const wh = [width, 500];
  const origin = [0, 0];
  const bounds = [origin, wh];

  return (
    <div style={{ width: "1100px", height: "600px" }}>
      <MapContainer
        style={{ height: "100%", minHeight: "100%" }}
        bounds={zoom ? undefined : bounds}
        boundsOptions={{
          padding: [0, 0]
        }}
        maxBounds={bounds}
        zoom={center ? zoom : …
Run Code Online (Sandbox Code Playgroud)

javascript css leaflet reactjs react-leaflet

2
推荐指数
1
解决办法
1812
查看次数

标签 统计

css ×1

javascript ×1

leaflet ×1

react-leaflet ×1

reactjs ×1