亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 R Leaflet 中實現一個(javascript)插件

在 R Leaflet 中實現一個(javascript)插件

慕碼人2483693 2023-02-23 10:05:52
我正在用 R 構建 Leaflet 應用程序。我想使用這個插件https://github.com/Turbo87/leaflet-sidebar 但是,我不知道從哪里開始。在 R 中實現 Javascript Leaflet 插件的指南無法提供幫助。有沒有人有我可以遵循的任何步驟/指導/代碼來在我的 R Leaflet 中實現插件?任何幫助將不勝感激。這是我目前所在的位置:sidebarPlugin <- htmlDependency("leaflet-sidebar", "0.2.0",                            src = c(href = "https://github.com/Turbo87/leaflet-sidebar.git"),                            script = "src/L.Control.Sidebar.js")registerPlugin <- function(map, plugin) {  map$dependencies <- c(map$dependencies, list(plugin))  map}testLeaflet <- leaflet() %>%  addTiles %>%  addPolylines(data = dijkjson)%>%  #register plugin on this map instance  registerPlugin(sidebarPlugin)%>%  addControl("Test2", position = "topright")%>%  # Add your custom JS logic here. The `this` keyword  # refers to the Leaflet (JS) map object.  onRender("function(el, x) {       var sidebar = L.control.sidebar('sidebar', {       position: 'left'}).addTo(this);       map.addControl(sidebar).addTo(this);       sidebar.show().addTo(this);       }")
查看完整描述

1 回答

?
冉冉說

TA貢獻1877條經驗 獲得超1個贊

也許你還沒有解決你的問題。第一步是確保您的 htmlDependency 源確實存在。根據您的路徑,我得到以下響應:{"error":"Not Found"}

jsdelivr以 application/javascript 格式提供大多數可通過 npm 和 github 獲得的 js 庫。使用它而不是你可以嘗試的原始 github 路徑:

sidebarPlugin <- htmltools::htmlDependency("L.Control.Sidebar", "0.2.1",
                            src = c(href = 'https://cdn.jsdelivr.net/gh/Turbo87/[email protected]/src'), 
                            script = 'L.Control.Sidebar.js', stylesheet = 'L.Control.Sidebar.css')



查看完整回答
反對 回復 2023-02-23
  • 1 回答
  • 0 關注
  • 98 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號