pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <legend id='7tNKW'><style id='7tNKW'><dir id='7tNKW'><q id='7tNKW'></q></dir></style></legend>

      <i id='7tNKW'><tr id='7tNKW'><dt id='7tNKW'><q id='7tNKW'><span id='7tNKW'><b id='7tNKW'><form id='7tNKW'><ins id='7tNKW'></ins><ul id='7tNKW'></ul><sub id='7tNKW'></sub></form><legend id='7tNKW'></legend><bdo id='7tNKW'><pre id='7tNKW'><center id='7tNKW'></center></pre></bdo></b><th id='7tNKW'></th></span></q></dt></tr></i><div class="0kuqeyo" id='7tNKW'><tfoot id='7tNKW'></tfoot><dl id='7tNKW'><fieldset id='7tNKW'></fieldset></dl></div>

        <small id='7tNKW'></small><noframes id='7tNKW'>

      1. <tfoot id='7tNKW'></tfoot>

          <bdo id='7tNKW'></bdo><ul id='7tNKW'></ul>
      2. 單擊傳單標記會將您帶到 URL

        Clicking a leaflet marker takes you to URL(單擊傳單標記會將您帶到 URL)
            <tbody id='GUcZw'></tbody>

          • <legend id='GUcZw'><style id='GUcZw'><dir id='GUcZw'><q id='GUcZw'></q></dir></style></legend>

              <i id='GUcZw'><tr id='GUcZw'><dt id='GUcZw'><q id='GUcZw'><span id='GUcZw'><b id='GUcZw'><form id='GUcZw'><ins id='GUcZw'></ins><ul id='GUcZw'></ul><sub id='GUcZw'></sub></form><legend id='GUcZw'></legend><bdo id='GUcZw'><pre id='GUcZw'><center id='GUcZw'></center></pre></bdo></b><th id='GUcZw'></th></span></q></dt></tr></i><div class="yo202ik" id='GUcZw'><tfoot id='GUcZw'></tfoot><dl id='GUcZw'><fieldset id='GUcZw'></fieldset></dl></div>

              <small id='GUcZw'></small><noframes id='GUcZw'>

              <tfoot id='GUcZw'></tfoot>
                • <bdo id='GUcZw'></bdo><ul id='GUcZw'></ul>
                  本文介紹了單擊傳單標記會將您帶到 URL的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  這里是 JS 解決方案.


                  在 R 中,添加帶有 URL 的彈出窗口:

                  In R, to add a Popup with a URL:

                  library(leaflet)
                  content <- paste(sep = "<br/>",
                                   "<b><a >Samurai Noodle</a></b>"
                  )
                  
                  leaflet() %>% addTiles() %>%
                    addPopups(-122.327298, 47.597131,  content,
                               options = popupOptions(closeButton = FALSE)
                    )
                  

                  添加一個標記也很簡單,當單擊該標記時,會在彈出窗口中提供一個 URL:

                  It's also straightforward to add a Marker that, when clicked, provides a URL in the popup:

                  leaflet() %>% addTiles() %>%
                    addMarkers(-122.327298, 47.597131, popup =  content,
                              options = popupOptions(closeButton = FALSE)
                    )
                  

                  也許某些自定義傳遞給 ... 中的傳單?

                  Perhaps something custom passed to leaflet in ...?

                  最后,自定義 JS 函數如何為每個地圖標記顯示不同的 URL?考慮示例 data.frame:

                  Lastly, how could a custom JS function display different URLs for each map marker? Consider the example data.frame:

                  df <- data.frame(url = c("https://stackoverflow.com/questions/tagged/python",
                                           "https://stackoverflow.com/questions/tagged/r")),
                                   lng = c(-122.327298, -122.337298),
                                   lat = c(47.597131,47.587131))
                  

                  <小時>

                  *這是以前問過的,但我問的是這個問題再次在這里并制作一個最小的,可重現的例子.


                  *This was previously asked, but I'm asking the question again here and making a minimal, reproducible example.

                  推薦答案

                  你可以使用 htmltoolshtmlwidgets 添加一個 onclick 事件javascript:

                  You could use htmltools or htmlwidgets to add an onclick event with javascript:

                  解決方案 1) 使用 htmltools:

                  library(leaflet)
                  map <- leaflet() %>% 
                    addTiles() %>%
                    addMarkers(-122.327298, 47.597131, popup =  'LINK',
                               options = popupOptions(closeButton = FALSE)
                    )
                  
                  library(htmltools)
                  browsable(
                    tagList(
                      list(
                        tags$head(
                          tags$script(
                            '
                           document.addEventListener("DOMContentLoaded", function(){
                             var marker = document.getElementsByClassName("leaflet-pane leaflet-marker-pane");
                             var openLink = function() {
                               window.open("https://www.stackoverflow.com")
                             };
                             marker[0].addEventListener("click", openLink, false);
                           })
                            '
                          )
                        ),
                        map
                      )
                    )
                  )
                  

                  解決方案 2 - 使用 htmlwidgets:

                  library(leaflet)
                  library(htmlwidgets)
                  leaflet() %>% 
                    addTiles() %>%
                    addMarkers(-122.327298, 47.597131, popup =  'LINK',
                               options = popupOptions(closeButton = FALSE)
                    ) %>%
                    onRender('
                      function(el, x) {
                        var marker = document.getElementsByClassName("leaflet-pane leaflet-marker-pane");
                        var openLink = function() {
                          window.open("https://www.stackoverflow.com")
                        };
                        marker[0].addEventListener("click", openLink, false);
                      }
                    ')
                  

                  每個標記的不同網址:

                  這是一種骯臟的方法,并顯示了一般方法.我沒有時間再次熟悉 JS 中的閉包以添加循環.

                  This is a dirty approach and shows the general way. I lack time to get comfortable with closures in JS again to add a loop.

                  可以看這里:addEventListener 使用 for 循環和傳遞值.并且可以通過 onRender 函數將數據從 R 傳遞到 JS.

                  One could look here: addEventListener using for loop and passing values. And data can be passed from R to JS with the onRender function.

                   jsCode <- paste0('
                   function(el, x) {
                    var marker = document.getElementsByClassName("leaflet-marker-icon leaflet-zoom-animated leaflet-interactive");
                    marker[0].onclick=function(){window.open("https://stackoverflow.com/questions/tagged/python");};
                    marker[1].onclick=function(){window.open("https://stackoverflow.com/questions/tagged/r");};
                  }
                   ')
                   
                   
                   library(leaflet)
                   library(htmlwidgets)
                   leaflet() %>% 
                     addTiles() %>%
                     addMarkers(lng = df$lng, lat = df$lat, popup =  'LINK',
                                options = popupOptions(closeButton = FALSE)
                     ) %>%
                     onRender(jsCode)
                   
                  

                  使用 addEventListener 中的方法,使用 for 循環和傳遞值,您可以遍歷數據以獲取每個標記的不同 url:

                  Using the approach from addEventListener using for loop and passing values, you can loop through the data to get different a url for each marker:

                  library(leaflet)
                  library(htmlwidgets)
                  df <- data.frame(url = c("https://stackoverflow.com/questions/tagged/python",
                                           "https://stackoverflow.com/questions/tagged/r"),
                                   lng = c(-122.327298, -122.337298),
                                   lat = c(47.597131,47.587131))
                  
                  jsCode <- '
                   function(el, x, data) {
                    var marker = document.getElementsByClassName("leaflet-marker-icon leaflet-zoom-animated leaflet-interactive");  
                    for(var i=0; i < marker.length; i++){
                      (function(){
                        var v = data.url[i];
                        marker[i].addEventListener("click", function() { window.open(v);}, false);
                       }()
                       ); 
                     }
                    }'
                  
                  leaflet() %>% 
                   addTiles() %>%
                   addMarkers(lng = df$lng, lat = df$lat, popup =  'LINK',
                              options = popupOptions(closeButton = FALSE)
                   ) %>%
                   onRender(jsCode, data=df)
                  

                  這篇關于單擊傳單標記會將您帶到 URL的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Check if a polygon point is inside another in leaflet(檢查一個多邊形點是否在傳單中的另一個內部)
                  Changing leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改傳單標記群集圖標顏色,繼承其余默認 CSS 屬性)
                  Trigger click on leaflet marker(觸發點擊傳單標記)
                  How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默認加載磁貼顏色?)
                  Add external geojson to leaflet layer(將外部geojson添加到傳單層)
                  Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側邊欄)
                  <legend id='DGSDt'><style id='DGSDt'><dir id='DGSDt'><q id='DGSDt'></q></dir></style></legend>

                  <small id='DGSDt'></small><noframes id='DGSDt'>

                        <tbody id='DGSDt'></tbody>

                        <bdo id='DGSDt'></bdo><ul id='DGSDt'></ul>
                        <i id='DGSDt'><tr id='DGSDt'><dt id='DGSDt'><q id='DGSDt'><span id='DGSDt'><b id='DGSDt'><form id='DGSDt'><ins id='DGSDt'></ins><ul id='DGSDt'></ul><sub id='DGSDt'></sub></form><legend id='DGSDt'></legend><bdo id='DGSDt'><pre id='DGSDt'><center id='DGSDt'></center></pre></bdo></b><th id='DGSDt'></th></span></q></dt></tr></i><div class="mo0wuay" id='DGSDt'><tfoot id='DGSDt'></tfoot><dl id='DGSDt'><fieldset id='DGSDt'></fieldset></dl></div>

                        • <tfoot id='DGSDt'></tfoot>
                            主站蜘蛛池模板: 大型果蔬切片机-水果冬瓜削皮机-洗菜机切菜机-肇庆市凤翔餐饮设备有限公司 | 杭州月嫂技术培训服务公司-催乳师培训中心报名费用-产后康复师培训机构-杭州优贝姆健康管理有限公司 | 假肢-假肢价格-假肢厂家-河南假肢-郑州市力康假肢矫形器有限公司 | 上海律师事务所_上海刑事律师免费咨询平台-煊宏律师事务所 | 发电机价格|发电机组价格|柴油发电机价格|柴油发电机组价格网 | 安徽净化工程设计_无尘净化车间工程_合肥净化实验室_安徽创世环境科技有限公司 | 电梯乘运质量测试仪_电梯安全评估测试仪-武汉懿之刻 | 电动不锈钢套筒阀-球面偏置气动钟阀-三通换向阀止回阀-永嘉鸿宇阀门有限公司 | 模型公司_模型制作_沙盘模型报价-中国模型网 | 亮点云建站-网站建设制作平台 | 云南外加剂,云南速凝剂,云南外加剂代加工-普洱澜湄新材料科技有限公司 | 智慧养老_居家养老_社区养老_杰佳通 | 模具硅橡胶,人体硅胶,移印硅胶浆厂家-宏图硅胶科技 | 北京晚会活动策划|北京节目录制后期剪辑|北京演播厅出租租赁-北京龙视星光文化传媒有限公司 | 安全,主动,被动,柔性,山体滑坡,sns,钢丝绳,边坡,防护网,护栏网,围栏,栏杆,栅栏,厂家 - 护栏网防护网生产厂家 | 氧化锆陶瓷_氧化锆陶瓷加工_氧化锆陶瓷生产厂家-康柏工业陶瓷有限公司 | 水环真空泵厂家,2bv真空泵,2be真空泵-淄博真空设备厂 | 脱硝喷枪-氨水喷枪-尿素喷枪-河北思凯淋环保科技有限公司 | 地磅-电子地磅维修-电子吊秤-汽车衡-无人值守系统-公路治超-鹰牌衡器 | 杭州标识标牌|文化墙|展厅|导视|户内外广告|发光字|灯箱|铭阳制作公司 - 杭州标识标牌|文化墙|展厅|导视|户内外广告|发光字|灯箱|铭阳制作公司 | 高楼航空障碍灯厂家哪家好_航空障碍灯厂家_广州北斗星障碍灯有限公司 | 粉末包装机-给袋式包装机-全自动包装机-颗粒-液体-食品-酱腌菜包装机生产线【润立机械】 | 健康管理师报名入口,2025年健康管理师考试时间信息网-网站首页 塑料造粒机「厂家直销」-莱州鑫瑞迪机械有限公司 | NMRV减速机|铝合金减速机|蜗轮蜗杆减速机|NMRV减速机厂家-东莞市台机减速机有限公司 | 手持式线材张力计-套帽式风量罩-深圳市欧亚精密仪器有限公司 | 丝印油墨_水性油墨_环保油墨油漆厂家_37国际化工 | 广东护栏厂家-广州护栏网厂家-广东省安麦斯交通设施有限公司 | 锂辉石检测仪器,水泥成分快速分析仪-湘潭宇科分析仪器有限公司 | 激光内雕_led玻璃_发光玻璃_内雕玻璃_导光玻璃-石家庄明晨三维科技有限公司 激光内雕-内雕玻璃-发光玻璃 | 北京翻译公司_同传翻译_字幕翻译_合同翻译_英语陪同翻译_影视翻译_翻译盖章-译铭信息 | 合肥注册公司|合肥代办营业执照、2024注册公司流程 | 依维柯自动挡房车,自行式国产改装房车,小型房车价格,中国十大房车品牌_南京拓锐斯特房车 - 南京拓锐斯特房车 | 车辆定位管理系统_汽车GPS系统_车载北斗系统 - 朗致物联 | 周口风机|周风风机|河南省周口通用风机厂| 意大利Frascold/富士豪压缩机_富士豪半封闭压缩机_富士豪活塞压缩机_富士豪螺杆压缩机 | 压力变送器-上海武锐自动化设备有限公司 | 超声波_清洗机_超声波清洗机专业生产厂家-深圳市好顺超声设备有限公司 | 宁夏活性炭_防护活性炭_催化剂载体炭-宁夏恒辉活性炭有限公司 | 行吊_电动单梁起重机_双梁起重机_合肥起重机_厂家_合肥市神雕起重机械有限公司 | SDG吸附剂,SDG酸气吸附剂,干式酸性气体吸收剂生产厂家,超过20年生产使用经验。 - 富莱尔环保设备公司(原名天津市武清县环保设备厂) | 郑州巴特熔体泵有限公司专业的熔体泵,熔体齿轮泵与换网器生产厂家 |