【问题标题】:react-simple-maps shos small and not centered mapreact-simple-maps 显示较小且未居中的地图
【发布时间】:2020-11-01 18:36:33
【问题描述】:

我正在使用 react-simple-maps 显示阿根廷的 SVG 地图,但问题是 react-simple-maps 以小尺寸显示地图并且未居中。我尝试了一些方法来修复它,但我不明白如何修复它。

这是我的代码所在的代码框:- https://codesandbox.io/s/basic-map-forked-9x1bl

【问题讨论】:

  • 因为你使用的viewBox。您可以尝试获取组 .rsm-geographies 的边界框并将数据用于 viewBox 的新值。请阅读getBBox()
  • 请尝试 viewBox="225 377 40 110"
  • 非常感谢,我会弄清楚getBBox()
  • @FernandoAzarías 你有想过这个吗?我也有同样的问题
  • @CeriWestcott 不,我没弄明白

标签: reactjs svg topojson react-simple-maps


【解决方案1】:

如果您遇到缩放问题,那么您可以尝试使用 ZoomableGroup 的 ZoomableGroup

你可以通过导入import { ZoomableGroup } from "react-simple-maps"来使用它

【讨论】:

  • 谢谢,我会尝试这种方法
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多