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

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

        <tfoot id='ZWYck'></tfoot>
      1. <small id='ZWYck'></small><noframes id='ZWYck'>

          <bdo id='ZWYck'></bdo><ul id='ZWYck'></ul>
      2. 如何在 Leaflet 中顯示超出特定縮放級別的標簽?

        How do I show a label beyond a certain zoom level in Leaflet?(如何在 Leaflet 中顯示超出特定縮放級別的標簽?)

          <tfoot id='4M4zX'></tfoot>

          <small id='4M4zX'></small><noframes id='4M4zX'>

          • <bdo id='4M4zX'></bdo><ul id='4M4zX'></ul>
                  <tbody id='4M4zX'></tbody>
                1. <legend id='4M4zX'><style id='4M4zX'><dir id='4M4zX'><q id='4M4zX'></q></dir></style></legend>
                2. <i id='4M4zX'><tr id='4M4zX'><dt id='4M4zX'><q id='4M4zX'><span id='4M4zX'><b id='4M4zX'><form id='4M4zX'><ins id='4M4zX'></ins><ul id='4M4zX'></ul><sub id='4M4zX'></sub></form><legend id='4M4zX'></legend><bdo id='4M4zX'><pre id='4M4zX'><center id='4M4zX'></center></pre></bdo></b><th id='4M4zX'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4M4zX'><tfoot id='4M4zX'></tfoot><dl id='4M4zX'><fieldset id='4M4zX'></fieldset></dl></div>

                  本文介紹了如何在 Leaflet 中顯示超出特定縮放級別的標簽?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我對 Leaflet 庫和 JavaScript 非常陌生,我一直在試圖弄清楚如何根據縮放級別顯示/隱藏傳單標簽(并且標記位于集群"中' 層).

                  I'm pretty new to the Leaflet library, and to JavaScript in general, and I'm stuck trying to figure out how to show/hide a leaflet Label based on the zoom level (and the markers are in a 'cluster' layer).

                  標記全部通過 AJAX 回調加載,然后我使用 onEachFeature 綁定彈出窗口和標簽,然后將 geoJson 標記層添加到地圖.

                  The markers are all loaded via AJAX callback and then I bind the popup and label using the onEachFeature, then I add the layer of geoJson markers to the map.

                  我只想在放大到某個級別時顯示標簽,但我沒有任何運氣.我也嘗試添加 leaflet.zoomcss.js 但我想我沒有正確使用它.

                  I'd like to only show the labels when zoomed in to some level, but I haven't had any luck. I also tried adding the leaflet.zoomcss.js but I guess I'm not using that correctly.

                  示例

                  var officesLayerGroup = L.markerClusterGroup();
                  var currentMakers;
                  function DiaplyLocalOffices(jqOffices) {
                  
                      currentMakers = new L.geoJson(jqOffices, {
                          style: function (feature) {
                              var c = feature.properties.markercolor;
                              if (feature.properties.OfficeID == 0) {
                                  c = 'yellow';
                              }
                              return { color: c };
                          },
                          pointToLayer: function (feature, latlng) {
                              return new L.CircleMarker(latlng, { radius: 7, fillOpacity: 0.5 });
                          },
                  
                          onEachFeature: bindOfficePopup
                      });
                      officesLayerGroup.addLayer(currentMakers);
                      map.addLayer(officesLayerGroup); 
                  }
                  
                  function bindOfficePopup(feature, layer) {
                      // This function adds the popup based on the information in the 'layer' or marker
                      // Keep track of the layer(marker)
                      feature.layer = layer;
                  
                      var props = feature.properties;
                      if (props) {
                          var desc = '<span id="feature-popup">';
                          //.. a bunch of other html added here!    
                          var warn = props.Warning ? props.Warning : null;
                          if (warn !== null) {
                              desc += '<font size="4" color="red"><strong><em>' + warn + '</em></strong></font></br>';
                          }
                          desc += '</span>';
                          layer.bindPopup(desc);
                          layer.bindLabel('Hi Label!', { noHide: true, className: 'my-css-styled-labels'});
                  
                      }
                  }
                  

                  我也嘗試過像這樣添加它,但也沒有用:

                  I've also tried adding it like this but that didn't work either:

                      layer.on({
                            zoomend: showLabel(e)
                      });
                  

                  然后是快速函數:

                  function showLabel(e) {
                      z = map.getZoom();
                      if (z > 6) {
                          layer.bindLabel("HIYA", { noHide: true, className: 'my-css-styled-labels' });
                      }
                  }
                  

                  但沒有運氣,即使為 leaflet.zoomcss.js

                  抱歉冗長,但我們將不勝感激!

                  Sorry for being lengthy, but any help would be really appreciated!

                  推薦答案

                  Leaflet 的圖層在縮放地圖時沒有觸發事件.實際的地圖實例確實如此.但是,當您開始擁有更多功能時,將事件處理程序綁定到每個功能將變成性能噩夢.您最好處理地圖縮放事件,然后獲取圖層中的所有要素并在需要時顯示標簽.例如:

                  Leaflet's layers don't have events fired when zooming the map. The actual map instance does. But binding an eventhandler to each feature would turn into a performance nightmare when you start having more features. You're better off handling the map zoomevent and then fetching all the features in your layer and showing the labels if needed. For example:

                  var geoJsonLayer = L.geoJson(featureCollection, {
                      onEachFeature: function (feature, layer) {
                          layer.bindLabel(feature.geometry.coordinates.toString());
                      }
                  }).addTo(map);
                  
                  var visible;
                  
                  // Attach map zoom handler
                  map.on('zoomend', function (e) {
                      // Check zoom level
                      if (map.getZoom() > 10) {
                          // Check if not already shown
                          if (!visible) {
                              // Loop over layers
                              geoJsonLayer.eachLayer(function (layer) {
                                  // Show label
                                  layer.showLabel();
                              });
                              // Set visibility flag
                              visible = true;
                          }
                      } else {
                          // Check if not already hidden
                          if (visible) {
                              // Loop over layers
                              geoJsonLayer.eachLayer(function (layer) {
                                  // Hide label
                                  layer.hideLabel();
                              });
                              // Set visibility flag
                              visible = false;
                          }
                      }
                  });
                  
                  // Fits to layer bounds which automaticly will fire the zoomevent
                  map.fitBounds(geoJsonLayer.getBounds());
                  

                  這是一個關于 Plunker 的工作示例:http://plnkr.co/edit/V8duPDjKlY48MTHOU35F?p=preview

                  Here's a working example on Plunker: http://plnkr.co/edit/V8duPDjKlY48MTHOU35F?p=preview

                  這篇關于如何在 Leaflet 中顯示超出特定縮放級別的標簽?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 - 在彈出窗口中獲取標記的緯度和經度)
                  <legend id='EKteF'><style id='EKteF'><dir id='EKteF'><q id='EKteF'></q></dir></style></legend>

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

                  <tfoot id='EKteF'></tfoot>
                      • <bdo id='EKteF'></bdo><ul id='EKteF'></ul>

                            <tbody id='EKteF'></tbody>

                        1. <i id='EKteF'><tr id='EKteF'><dt id='EKteF'><q id='EKteF'><span id='EKteF'><b id='EKteF'><form id='EKteF'><ins id='EKteF'></ins><ul id='EKteF'></ul><sub id='EKteF'></sub></form><legend id='EKteF'></legend><bdo id='EKteF'><pre id='EKteF'><center id='EKteF'></center></pre></bdo></b><th id='EKteF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='EKteF'><tfoot id='EKteF'></tfoot><dl id='EKteF'><fieldset id='EKteF'></fieldset></dl></div>
                          • 主站蜘蛛池模板: 国产精久久| 一区二区三区视频在线 | 日韩国产欧美 | 日本色网址| 懂色av蜜臀av粉嫩av分享 | 精品一区av| 成人小视频在线 | 国产资源在线播放 | 日韩欧美在线观看视频 | 51调教丨国产调教视频 | 激情久久久| 国产黄在线观看 | 亚洲一区久久 | 国产精品久久久久久中文字 | 国产亚洲视频在线观看 | 天堂网av在线 | 国产精品一区二区在线播放 | 亚洲福利在线观看 | 亚洲精品乱码久久久久久蜜桃91 | 欧美精品xxx | 黄色一级大片在线免费看国产一 | 四虎成人精品 | 久色精品 | 狠狠躁夜夜躁人爽 | 成人网av | 日韩中文字幕 | 亚洲在线免费观看 | 色综合天天综合网国产成人网 | 中文字幕日韩高清 | 欧美不卡一区二区三区 | 操操影院 | 国产一区精品视频 | 国产探花视频在线观看 | 午夜黄视频| 国产中文字幕在线播放 | 国产精品一区二区在线播放 | 久久久久久久久久久久久久 | 在线观看a视频 | 波多野结衣乳巨码无在线观看 | 国产一级片在线 | av一二三|