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>
                            主站蜘蛛池模板: 鹤壁创新仪器公司-全自动量热仪,定硫仪,煤炭测硫仪,灰熔点测定仪,快速自动测氢仪,工业分析仪,煤质化验仪器 | 真空乳化机-灌装封尾机-首页-温州精灌 | hdpe土工膜-防渗膜-复合土工膜-长丝土工布价格-厂家直销「恒阳新材料」-山东恒阳新材料有限公司 ETFE膜结构_PTFE膜结构_空间钢结构_膜结构_张拉膜_浙江萬豪空间结构集团有限公司 | POS机办理_个人POS机免费领取 - 银联POS机申请首页 | 专业的压球机生产线及解决方案厂家-河南腾达机械厂 | 福州甲醛检测-福建室内空气检测_环境检测_水质检测-福建中凯检测技术有限公司 | 偏心半球阀-电动偏心半球阀-调流调压阀-旋球阀-上欧阀门有限公司 | 盘式曝气器-微孔曝气器-管式曝气器-曝气盘-斜管填料 | 郑州市前程水处理有限公司 | 深圳希玛林顺潮眼科医院(官网)│深圳眼科医院│医保定点│香港希玛林顺潮眼科中心连锁品牌 | 嘉兴恒升声级计-湖南衡仪声级计-杭州爱华多功能声级计-上海邦沃仪器设备有限公司 | 塑料托盘厂家直销-吹塑托盘生产厂家-力库塑业【官网】 | 智慧养老_居家养老_社区养老_杰佳通 | 上海盐水喷雾试验机_两厢式冷热冲击试验箱-巨怡环试 | 流变仪-热分析联用仪-热膨胀仪厂家-耐驰科学仪器商贸 | TPE_TPE热塑性弹性体_TPE原料价格_TPE材料厂家-惠州市中塑王塑胶制品公司- 中塑王塑胶制品有限公司 | 亳州网络公司 - 亳州网站制作 - 亳州网站建设 - 亳州易天科技 | 涂层测厚仪_漆膜仪_光学透过率仪_十大创新厂家-果欧电子科技公司 | 踏板力计,制动仪,非接触多功能速度仪,逆反射系数测试仪-创宇 | 黑龙江「京科脑康」医院-哈尔滨失眠医院_哈尔滨治疗抑郁症医院_哈尔滨精神心理医院 | 黄石妇科医院_黄石东方女子医院_黄石东方妇产医院怎么样 | 润东方环保空调,冷风机,厂房车间降温设备-20年深圳环保空调生产厂家 | 石家庄小程序开发_小程序开发公司_APP开发_网站制作-石家庄乘航网络科技有限公司 | 金属抛光机-磁悬浮抛光机-磁力研磨机-磁力清洗机 - 苏州冠古科技 | 深圳高新投三江工业消防解决方案提供厂家_服务商_园区智慧消防_储能消防解决方案服务商_高新投三江 | 不锈钢钢格栅板_热浸锌钢格板_镀锌钢格栅板_钢格栅盖板-格美瑞 | STRO|DTRO-STRO反渗透膜(科普)_碟滤 | 压接机|高精度压接机|手动压接机|昆明可耐特科技有限公司[官网] 胶泥瓷砖胶,轻质粉刷石膏,嵌缝石膏厂家,腻子粉批发,永康家德兴,永康市家德兴建材厂 | 路斯特伺服驱动器维修,伦茨伺服驱动器维修|万骏自动化百科 | 阁楼货架_阁楼平台_仓库仓储设备_重型货架_广州金铁牛货架厂 | 六维力传感器_六分量力传感器_模腔压力传感器-南京数智微传感科技有限公司 | 郑州巴特熔体泵有限公司专业的熔体泵,熔体齿轮泵与换网器生产厂家 | TPE塑胶原料-PPA|杜邦pom工程塑料、PPSU|PCTG材料、PC/PBT价格-悦诚塑胶 | 合肥风管加工厂-安徽螺旋/不锈钢风管-通风管道加工厂家-安徽风之范 | 天长市晶耀仪表有限公司 | 预制围墙_工程预制围墙_天津市瑞通建筑材料有限公司 | 招商帮-一站式网络营销服务|搜索营销推广|信息流推广|短视视频营销推广|互联网整合营销|网络推广代运营|招商帮企业招商好帮手 | 成都顶呱呱信息技术有限公司-贷款_个人贷款_银行贷款在线申请 - 成都贷款公司 | 复合土工膜厂家|hdpe防渗土工膜|复合防渗土工布|玻璃纤维|双向塑料土工格栅-安徽路建新材料有限公司 | 德国进口电锅炉_商用电热水器_壁挂炉_电采暖器_电热锅炉[德国宝] | 智成电子深圳tdk一级代理-提供TDK电容电感贴片蜂鸣器磁芯lambda电源代理经销,TDK代理商有哪些TDK一级代理商排名查询。-深圳tdk一级代理 | 维泰克Veertek-锂电池微短路检测_锂电池腐蚀检测_锂电池漏液检测 |