如何解决浏览器与传单的不一致::addMapPane() 函数
每当使用 leaflet
函数创建不同的窗格时,我都会在我的 blogdown
网站中集成 addMapPane()
地图。问题是,使用 Safari 时,一切正常,但使用 Chrome 时,图块根本不显示。
可以查看此特定示例 here(请同时使用 Safari 和 Chrome 打开它以了解差异)。
通过编写这个非常简单的 Rmd
文档可以轻松地隔离问题:
---
title: Browsers inconsistency with tiles
output: html_document
---
```{r}
library(leaflet)
leaflet(
width = "100%"
) %>%
addMapPane(
name = "test",zIndex = 500L
) %>%
addTiles(
options = tileOptions(
pane = "test"
)
)
```
使用 Safari 时,html
页面呈现如下。
这是预期的输出,一切正常。但是,在 Chrome 中打开完全相同的 html
时,我看到以下内容:
正如人们所见,图块不是用 Chrome 渲染的。由于浏览器似乎造成了问题,我想这可能与 css
相关,但我不知道如何确认或(更好)解决此问题。
有人知道这个吗?
解决方法
将此 css 添加到您的文档中:
img.leaflet-tile {
max-width: none !important;
max-height: none !important;
}
我不知道为什么它可以在 Safari 中运行,为什么不能在 Firefox 和 Chrome 中运行,但它与这个 css 类有关,因为它没有被应用:
.leaflet-container .leaflet-overlay-pane svg,.leaflet-container .leaflet-marker-pane img,.leaflet-container .leaflet-shadow-pane img,.leaflet-container .leaflet-tile-pane img,.leaflet-container img.leaflet-image-layer {
max-width: none !important;
max-height: none !important;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。