[問題] R Leaflet讀取JS plugin方法

看板R_Language作者 (混沌的大氣)時間7年前 (2018/03/05 19:18), 編輯推噓0(005)
留言5則, 2人參與, 7年前最新討論串1/1
[問題類型]: 經驗諮詢 [軟體熟悉度]: 使用者(已經有用R 做過不少作品) [問題敘述]: 各位好 最近在github找到在Leaflet畫風標(windbarb)的JS套件 我照著在R Leaflet運用JS套件的方法去寫程式碼 執行之後地圖可開啟,但無法顯示出風標,也沒有任何錯誤訊息 不知從何處debug,感覺是JS部分沒吃進去 懇請有用處理過類似語法的前輩指點,謝謝! 風標JS套件Github https://github.com/JoranBeaufort/Leaflet.windbarb R使用Leaflet JS套件方法 https://gist.github.com/jcheng5/c084a59717f18e947a17955007dc5f92 [程式範例]: library(leaflet) library(htmltools) library(htmlwidgets) windbarb <- htmlDependency("leaflet-windbarb", "0.0.1", c(href = "https://github.com/JoranBeaufort/Leaflet.windbarb/blob/master/src/"), script = "leaflet-windbarb.js") registerPlugin <- function(map, plugin) { map$dependencies <- c(map$dependencies, list(plugin)) map } # 下面JS部分是直接拿風標github的範例語法 leaflet() %>% addTiles() %>% setView(7.222309, 47.11285, 12) %>% registerPlugin(windbarb) %>% onRender('function(el, x) { var meteoPoints = [ [ 47.11285 , 7.222309, 5, 190], [ 47.085272, 7.20377 , 30, 90], [ 47.092285, 7.156734, 47, 170], ]; meteoPoints.forEach(function(p){ var icon = L.WindBarb.icon({deg: p[3], speed: p[2]}); var marker = L.marker([p[0],p[1]], {icon: icon}).addTo(this); });') [環境敘述]: R 3.4.3 + Win 7 [關鍵字]: Leaflet / Javascript -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.226.64.125 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1520248733.A.502.html

03/05 20:08, 7年前 , 1F
你如果用瀏覽器開啟後,再打開瀏覽器的javascript除錯器
03/05 20:08, 1F

03/05 20:09, 7年前 , 2F
有沒有出現什麼錯誤訊息?
03/05 20:09, 2F

03/05 20:23, 7年前 , 3F
Chrome顯示its MIME type is not executable
03/05 20:23, 3F

03/05 20:23, 7年前 , 4F
另外還有找不到icon的屬性
03/05 20:23, 4F

03/06 07:30, 7年前 , 5F
問題已經找到了 是scr網址寫法有錯導致失敗
03/06 07:30, 5F
文章代碼(AID): #1QdIUTK2 (R_Language)
文章代碼(AID): #1QdIUTK2 (R_Language)