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

    <legend id='nBGgq'><style id='nBGgq'><dir id='nBGgq'><q id='nBGgq'></q></dir></style></legend>

        <tfoot id='nBGgq'></tfoot>
        • <bdo id='nBGgq'></bdo><ul id='nBGgq'></ul>
        <i id='nBGgq'><tr id='nBGgq'><dt id='nBGgq'><q id='nBGgq'><span id='nBGgq'><b id='nBGgq'><form id='nBGgq'><ins id='nBGgq'></ins><ul id='nBGgq'></ul><sub id='nBGgq'></sub></form><legend id='nBGgq'></legend><bdo id='nBGgq'><pre id='nBGgq'><center id='nBGgq'></center></pre></bdo></b><th id='nBGgq'></th></span></q></dt></tr></i><div class="epkfx2b" id='nBGgq'><tfoot id='nBGgq'></tfoot><dl id='nBGgq'><fieldset id='nBGgq'></fieldset></dl></div>
      1. <small id='nBGgq'></small><noframes id='nBGgq'>

        為傳單中的標記分配 ID

        Assign ID to marker in leaflet(為傳單中的標記分配 ID)

        <tfoot id='T04IN'></tfoot>

        <legend id='T04IN'><style id='T04IN'><dir id='T04IN'><q id='T04IN'></q></dir></style></legend>
      2. <i id='T04IN'><tr id='T04IN'><dt id='T04IN'><q id='T04IN'><span id='T04IN'><b id='T04IN'><form id='T04IN'><ins id='T04IN'></ins><ul id='T04IN'></ul><sub id='T04IN'></sub></form><legend id='T04IN'></legend><bdo id='T04IN'><pre id='T04IN'><center id='T04IN'></center></pre></bdo></b><th id='T04IN'></th></span></q></dt></tr></i><div class="or33ywb" id='T04IN'><tfoot id='T04IN'></tfoot><dl id='T04IN'><fieldset id='T04IN'></fieldset></dl></div>
          <bdo id='T04IN'></bdo><ul id='T04IN'></ul>

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

                <tbody id='T04IN'></tbody>
                  本文介紹了為傳單中的標記分配 ID的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  所以我嘗試在foursquare上實現結果:https://foursquare.com/explore?cat=drinks&mode=url&near=Paris 當您點擊地圖上的標記時,它會滾動瀏覽屏幕右側列出的餐館到臨時餐廳,并通過 CSS 突出顯示它.相反,當您點擊列表中的餐廳時,它會在地圖上突出顯示它.

                  So i try to achieve a result as on foursquare: https://foursquare.com/explore?cat=drinks&mode=url&near=Paris which is when you clik on a marker on the map, it scrolls through the listed of restaurants on the right -hand side of the screen to the ad hoc restaurant, and highlights it through CSS. Conversely, when you click on the restaurant on the list, it highlights it on the map.

                  我正在使用 skobbler/傳單.我想我可以通過動態修改 CSS 來實現這一點,如下例所示:http://jsfiddle.net/gU4sw/7/ + 滾動到頁面中已經存在的目標腳本.

                  I am using skobbler/leaflet. I think I can achieve this by amending dynamically CSS as shown in this example: http://jsfiddle.net/gU4sw/7/ + a scroll to destination script already in place in the page.

                  然而,為了實現這一點,我似乎需要在標記內分配一個 ID(下面的 2 個標記):

                  To achieve this however, it looks like I need to assign an ID within the markers (2 markers below):

                  var marker = L.marker([52.52112, 13.40554]).addTo(map);
                  marker.bindPopup("Hello world!<br>I am a popup1.", { offset: new L.Point(-1, -41) }).openPopup();
                  
                  var marker = L.marker([52.53552, 13.41994]).addTo(map);
                  marker.bindPopup("Hello world!<br>I am a popup2.", { offset: new L.Point(-1, -41) }).openPopup();
                  

                  問題是:如何分配標記 ID 以觸發我的 html 頁面中相應元素的 css 更改?

                  Question is: How can I assign an marker ID to trigger css change in the corresponding element within my html page?

                  我對 JS 的了解非常有限,但可能有一個很好且簡單的解決方案,謝謝

                  My knowledge of JS is very limited, but may be there's a nice and easy solution out there, thx

                  推薦答案

                  我一直在尋找一個很好的方法來做到這一點,據我所知,仍然沒有內置的方法(使用傳單)給一個標記一個ID.我知道我回答這個問題有點晚了,但希望它能幫助其他偶然發現這個問題的人.據我所知,這里有兩個主要問題:

                  I've been looking for a nice way to do this and as far as I can tell there is still no built-in way (using leaflet) to give a marker an ID. I know I'm a bit late to answering this but hopefully it will help others who stumble upon this question. As far as I can tell there are two main issues here:

                  問題 #1:除非您將標記保存到對象或地圖中,如下所述,否則以后沒有簡單的編程方式可以訪問它們.例如 - 用戶點擊地圖外部的東西,對應于地圖內部的標記.

                  Problem #1: Unless you save your markers to an object or map, described below, there is no easy programmatic way of accessing them later on. For example - A user clicks something OUTSIDE the map that corresponds to a marker INSIDE the map.

                  問題 2:當用戶單擊地圖內部的標記時,沒有內置方法可以檢索該標記的 ID,然后使用它來突出顯示相應的元素或觸發地圖外部的操作.

                  Problem #2: When a user clicks on a marker INSIDE the map, there is no built in way to retrieve the ID of that marker and then use it to highlight a corresponding element or trigger an action OUTSIDE the map.

                  使用其中一個或多個選項將有助于解決上述問題.我將從上一個答案中提到的那個開始.這是工作筆,它包含以下所有代碼.

                  Using a one or more of these options will help address the issues described above. I'll start with the one mentioned in the previous answer. Here is the working pen, which holds all the code found below.

                  選項 #1:使用硬編碼或動態 ID 將每個標記保存在對象內 -

                  Option #1: Save each marker, using a hardcoded or dynamic ID, inside an object -

                  // Create or retrieve the data
                  var data = [
                      {
                        name: 'Bob',
                        latLng: [41.028, 28.975],
                        id: '2342fc7'
                      }, {...}, {...}
                  ];
                  
                  // Add an object to save markers
                  var markers = {};
                  
                  // Loop through the data
                  for (var i = 0; i < data.length; i++) {
                    var person = data[i];
                  
                    // Create and save a reference to each marker
                    markers[person.id] = L.marker(person.latLng, {
                      ...
                    }).addTo(map);
                  }
                  

                  與其他答案類似,您現在可以使用 - 訪問單個標記

                  Similar to the other answer you can now access a single marker by using -

                  var marker = markers.2342fc7; // or markers['2342fc7']
                  

                  選項 #2:

                  雖然傳單沒有為標記提供內置的id"選項,但您可以通過訪問 ._icon 屬性直接將 ID 添加到元素:

                  While leaflet doesn't provide a built-in 'id' option for markers, you can add the an ID to the element directly by accessing ._icon property:

                  // Create and save a reference to each marker
                  markers[person.id] = L.marker(person.latLng, {...}).addTo(map);
                  
                  // Add the ID
                  markers[person.id]._icon.id = person.id;
                  

                  現在,當您處理點擊事件時,很容易獲得該標記的 ID:

                  Now when you handle click events, it's easy as pie to get that marker's ID:

                  $('.leaflet-marker-icon').on('click', function(e) {
                     // Use the event to find the clicked element
                     var el = $(e.srcElement || e.target),
                         id = el.attr('id');
                  
                      alert('Here is the markers ID: ' + id + '. Use it as you wish.')
                  });
                  

                  選項 #3:

                  另一種方法是使用 layerGroup 接口.它提供了一個方法,getLayer,聽起來就像使用 ID 獲取我們的標記是完美的.但是,目前,Leaflet 不提供任何方式來指定自定義 ID 或名稱.Github 上的這個 issue 討論了應該如何做到這一點.但是,您可以像這樣獲取并保存任何標記(或 iLayer )的自動生成 ID:

                  Another approach would be use the layerGroup interface. It provides a method, getLayer, that sounds like it would be perfect get our markers using an ID. However, at this time, Leaflet does not provide any way to specify a custom ID or name. This issue on Github discusses how this should be done. However you can get and save the auto-generated ID of any Marker (or iLayer for that matter) like so:

                  var group = L.layerGroup()
                  
                  people.forEach(person => {
                      // ... create marker
                      group.addLayer( marker );
                      person.marker_id = group.getLayerId(marker)
                  })
                  

                  現在我們已經將每個標記的 ID 與數據數組中的每個支持對象一起保存,我們稍后可以輕松地獲取標記,如下所示:

                  Now that we have every marker's ID saved with each backing object in our array of data we can easily get the marker later on like so:

                  group.getLayer(person.marker_id)
                  

                  有關完整示例,請參閱 這支筆...

                  See this pen for a full example...

                  選項 #4:

                  如果您有時間,最簡潔的方法是擴展傳單的標記類以干凈地處理您的個人需求.您可以向選項添加 id 或將自定義 HTML 插入具有您的 id/class 的標記中.有關這方面的更多信息,請參閱 文檔.

                  The cleanest way to do this, if you have the time, would be to extend the leaflet's marker class to handle your individual needs cleanly. You could either add an id to the options or insert custom HTML into the marker that has your id/class. See the documentation for more info on this.

                  您也可以使用 circleMarker,在 路徑選項,你會看到 className 有一個選項,可以很好地設置相似標記組的樣式.

                  You can also you use the circleMarker which, in the path options, you will see has an option for className which can be nice for styling groups of similar markers.

                  樣式:

                  幾乎忘記了您最初的問題是為了造型而提出的......只需使用 ID 來訪問各個元素:

                  Almost forgot that your original question was posed for the purpose of styling... simply use the ID to access individual elements:

                  .leaflet-marker-icon#2342fc7 { ... }
                  

                  結論

                  我還將提到圖層和功能組提供了另一種與標記交互的好方法.這是一個 問題 討論這一點.隨意修改或分叉 first 或 第二支筆 如果我遺漏了什么,請發表評論.

                  Conclusion

                  I'll also mention that layer and feature groups provide another great way to interface with markers. Here is a question that discusses this a bit. Feel free to tinker with, or fork either the first or second pen and comment if I've missed something.

                  這篇關于為傳單中的標記分配 ID的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 中的默認加載磁貼顏色?)
                  Adding Leaflet layer control to sidebar(將 Leaflet 圖層控件添加到側邊欄)
                  Leaflet - get latitude and longitude of a marker inside a pop-up(Leaflet - 在彈出窗口中獲取標記的緯度和經度)

                      <bdo id='5dOo1'></bdo><ul id='5dOo1'></ul>

                        • <legend id='5dOo1'><style id='5dOo1'><dir id='5dOo1'><q id='5dOo1'></q></dir></style></legend>

                          <small id='5dOo1'></small><noframes id='5dOo1'>

                            <tbody id='5dOo1'></tbody>
                        • <tfoot id='5dOo1'></tfoot>
                            <i id='5dOo1'><tr id='5dOo1'><dt id='5dOo1'><q id='5dOo1'><span id='5dOo1'><b id='5dOo1'><form id='5dOo1'><ins id='5dOo1'></ins><ul id='5dOo1'></ul><sub id='5dOo1'></sub></form><legend id='5dOo1'></legend><bdo id='5dOo1'><pre id='5dOo1'><center id='5dOo1'></center></pre></bdo></b><th id='5dOo1'></th></span></q></dt></tr></i><div class="8hsrtdy" id='5dOo1'><tfoot id='5dOo1'></tfoot><dl id='5dOo1'><fieldset id='5dOo1'></fieldset></dl></div>
                            主站蜘蛛池模板: 强效碱性清洗剂-实验室中性清洗剂-食品级高纯氮气发生器-上海润榕科学器材有限公司 | 楼承板设备-楼承板成型机-免浇筑楼承板机器厂家-捡来 | 世界箱包品牌十大排名,女包小众轻奢品牌推荐200元左右,男包十大奢侈品牌排行榜双肩,学生拉杆箱什么品牌好质量好 - Gouwu3.com | 废气处理设备-工业除尘器-RTO-RCO-蓄热式焚烧炉厂家-江苏天达环保设备有限公司 | 地埋式垃圾站厂家【佳星环保】小区压缩垃圾中转站转运站 | 制丸机,小型中药制丸机,全自动制丸机价格-甘肃恒跃制药设备有限公司 | 冷库安装厂家_杭州冷库_保鲜库建设-浙江克冷制冷设备有限公司 | 耐腐蚀泵,耐腐蚀真空泵,玻璃钢真空泵-淄博华舜耐腐蚀真空泵有限公司 | 大立教育官网-一级建造师培训-二级建造师培训-造价工程师-安全工程师-监理工程师考试培训 | 柴油发电机组_柴油发电机_发电机组价格-江苏凯晨电力设备有限公司 | 热处理温控箱,热处理控制箱厂家-吴江市兴达电热设备厂 | 冲击式破碎机-冲击式制砂机-移动碎石机厂家_青州市富康机械有限公司 | 航拍_专业的无人机航拍摄影门户社区网站_航拍网 | 浙江美尔凯特智能厨卫股份有限公司| 珠海冷却塔降噪维修_冷却塔改造报价_凉水塔风机维修厂家- 广东康明节能空调有限公司 | ET3000双钳形接地电阻测试仪_ZSR10A直流_SXJS-IV智能_SX-9000全自动油介质损耗测试仪-上海康登 | 欧景装饰设计工程有限公司-无锡欧景装饰官网 | 二手电脑回收_二手打印机回收_二手复印机回_硒鼓墨盒回收-广州益美二手电脑回收公司 | 吉祥新世纪铝塑板_生产铝塑板厂家_铝塑板生产厂家_临沂市兴达铝塑装饰材料有限公司 | 专业的压球机生产线及解决方案厂家-河南腾达机械厂 | 锥形螺带干燥机(新型耙式干燥机)百科-常州丰能干燥工程 | 亳州网络公司 - 亳州网站制作 - 亳州网站建设 - 亳州易天科技 | 低压载波电能表-单相导轨式电能表-华邦电力科技股份有限公司-智能物联网综合管理平台 | 汝成内控-行政事业单位内部控制管理服务商 | 螺杆式冷水机-低温冷水机厂家-冷冻机-风冷式-水冷式冷水机-上海祝松机械有限公司 | 除尘器布袋骨架,除尘器滤袋,除尘器骨架,电磁脉冲阀膜片,卸灰阀,螺旋输送机-泊头市天润环保机械设备有限公司 | POM塑料_PBT材料「进口」聚甲醛POM杜邦原料、加纤PBT塑料报价格找利隆塑料 | 包装机_厂家_价格-山东包装机有限公司 | 威廉希尔WilliamHill·足球(中国)体育官方网站 | 小型数控车床-数控车床厂家-双头数控车床 | 密集柜_档案密集柜_智能密集架_密集柜厂家_密集架价格-智英伟业 密集架-密集柜厂家-智能档案密集架-自动选层柜订做-河北风顺金属制品有限公司 | 品牌策划-品牌设计-济南之式传媒广告有限公司官网-提供品牌整合丨影视创意丨公关活动丨数字营销丨自媒体运营丨数字营销 | 多功能三相相位伏安表-变压器短路阻抗测试仪-上海妙定电气 | 亮点云建站-网站建设制作平台 | 钢制拖链生产厂家-全封闭钢制拖链-能源钢铝拖链-工程塑料拖链-河北汉洋机械制造有限公司 | lcd条形屏-液晶长条屏-户外广告屏-条形智能显示屏-深圳市条形智能电子有限公司 | 北京模型公司-工业模型-地产模型-施工模型-北京渝峰时代沙盘模型制作公司 | 搜木网 - 木业全产业链交易平台,免费搜货、低价买货! | 楼承板-钢筋楼承板-闭口楼承板-无锡优贝斯楼承板厂 | 防爆正压柜厂家_防爆配电箱_防爆控制箱_防爆空调_-盛通防爆 | 气动隔膜泵-电动隔膜泵-循环热水泵-液下排污/螺杆/管道/化工泵「厂家」浙江绿邦 |