[英]How to set preferCanvas flag to True in Leaflet for R
I am using Leaflet R package for rendering Leaflet map. 我正在使用Leaflet R包来渲染Leaflet地图。 I want to render my map with Canvas instead of SVG.
我想用Canvas而不是SVG渲染地图。 For this to achieve I need to set preferCanvas flag to true in Leaflet Options.
为此,我需要在Leaflet Options中将preferredCanvas标志设置为true。 But I am not able to do so in Leaflet for R (map still renders in SVG).
但是我不能在Leaflet for R中这样做(地图仍在SVG中渲染)。 Here is the working demo of Canvas map with JavaScript.
这是使用JavaScript的Canvas地图的工作演示。
Server.R: Server.R:
output$map <- renderLeaflet({
leaflet(
options = leafletOptions(preferCanvas = TRUE)
) %>%
setMaxBounds(lng1 = -180, lng2 = +180, lat1 = -90, lat2 = +90)
})
observe({
if(!is.null(input$map_bounds)){
if(input$map_zoom<3){
boundsBuff<- input$map_bounds
leafletProxy("map") %>%
setView(lng=(boundsBuff$north + boundsBuff$south)/2,
lat=(boundsBuff$east + boundsBuff$west)/2,
zoom = 3
)
}
})
UI.R: UI.R:
leafletOutput("map", width = "100%", height = "100%")
As per this Leaflet documentation, it seems I am doing it correctly but still it's not working, What I am doing wrong here? 根据本 Leaflet文档,似乎我做得正确,但仍然无法正常工作,这里我做错了什么?
I think it is bug in Leaflet, which has now been resolved (see CHANGELOG version 1.3.2 (2018-07-17) ) "Respect the preferCanvas option in all panes (#6019 by mjumbewu)" 我认为这是Leaflet中的错误,现已解决(请参阅CHANGELOG版本1.3.2(2018-07-17))“在所有窗格中均使用preferredCanvas选项(mjumbewu#6019)”
Docs from R's Leaflet package August 27, 2018 refers to Leaflet v. 1.3.1 R的Leaflet软件包中的文档于2018年8月27日引用Leaflet 1.3.1版
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.