久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <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="qwawimqqmiuu" 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="qwawimqqmiuu" 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="qwawimqqmiuu" id='DGSDt'><tfoot id='DGSDt'></tfoot><dl id='DGSDt'><fieldset id='DGSDt'></fieldset></dl></div>

                        • <tfoot id='DGSDt'></tfoot>
                            主站蜘蛛池模板: 日本不卡一区二区三区在线观看 | 国产激情在线观看视频 | 毛片高清| 亚洲精品乱码久久久久久黑人 | 天天玩夜夜操 | 亚洲自拍一区在线观看 | 久久人操 | 国产欧美一区二区三区另类精品 | 欧美日韩高清一区二区三区 | 成人免费视频网站 | 成人精品免费视频 | 99riav国产一区二区三区 | 天堂中文在线观看 | 国产我和子的乱视频网站 | 中文字幕日韩专区 | 国产精品污www一区二区三区 | 亚洲精品黄色 | 精品一区二区电影 | 亚洲 中文 欧美 日韩 在线观看 | 综合色站导航 | 色.com| 亚洲精品视频免费观看 | 91av免费观看| 亚洲综合在线一区二区 | 一级免费看片 | 久久r精品| 日韩av免费在线电影 | 国产成人精品一区二区三区 | 亚洲高清成人在线 | 新91| 国产视频中文字幕 | 黄色av网站在线观看 | 久久精品国产99国产 | 国产精品a久久久久 | 黄色欧美视频 | 国产一区二区三区精品久久久 | 一级黄色毛片子 | 中文字幕第一页在线 | 日韩免费在线观看视频 | 日韩av第一页 | www.日本在线观看 |