<bdo id='R8fPX'></bdo><ul id='R8fPX'></ul>
      <i id='R8fPX'><tr id='R8fPX'><dt id='R8fPX'><q id='R8fPX'><span id='R8fPX'><b id='R8fPX'><form id='R8fPX'><ins id='R8fPX'></ins><ul id='R8fPX'></ul><sub id='R8fPX'></sub></form><legend id='R8fPX'></legend><bdo id='R8fPX'><pre id='R8fPX'><center id='R8fPX'></center></pre></bdo></b><th id='R8fPX'></th></span></q></dt></tr></i><div id='R8fPX'><tfoot id='R8fPX'></tfoot><dl id='R8fPX'><fieldset id='R8fPX'></fieldset></dl></div>
    1. <tfoot id='R8fPX'></tfoot>

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

      1. <legend id='R8fPX'><style id='R8fPX'><dir id='R8fPX'><q id='R8fPX'></q></dir></style></legend>

        如何在传单地图上突出显示选定的行?

        时间:2023-08-08
      2. <small id='5FPy7'></small><noframes id='5FPy7'>

            <tbody id='5FPy7'></tbody>
          • <tfoot id='5FPy7'></tfoot>
            <i id='5FPy7'><tr id='5FPy7'><dt id='5FPy7'><q id='5FPy7'><span id='5FPy7'><b id='5FPy7'><form id='5FPy7'><ins id='5FPy7'></ins><ul id='5FPy7'></ul><sub id='5FPy7'></sub></form><legend id='5FPy7'></legend><bdo id='5FPy7'><pre id='5FPy7'><center id='5FPy7'></center></pre></bdo></b><th id='5FPy7'></th></span></q></dt></tr></i><div id='5FPy7'><tfoot id='5FPy7'></tfoot><dl id='5FPy7'><fieldset id='5FPy7'></fieldset></dl></div>

                  <bdo id='5FPy7'></bdo><ul id='5FPy7'></ul>
                  <legend id='5FPy7'><style id='5FPy7'><dir id='5FPy7'><q id='5FPy7'></q></dir></style></legend>
                  本文介绍了如何在传单地图上突出显示选定的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想画一张地图,上面画了几条路线.

                  I want to draw a map with few routes drawn on it.

                  我想要一个带有数字 1,..,n 的保管箱

                  I want to have a dropbox with numbers 1,..,n

                  当下拉框中的一个项目被选中时,相应的路线会在地图上突出显示.

                  when an item in the dropbox is chosen, the corresponding route is highlighted on the map.

                  我已经开始使用传单"了.

                  I have started using "leaflet".

                  如何突出显示一行?我使用了重量",但它更像是一条线的边界.我想看到这条线越来越粗.

                  how do I highlight a line? I have used "weight" but it's more a border to a line. I would like to see the line is getting bolder.

                  这是我的代码:

                  document.onload = loadMap();
                  
                  function loadMap() {
                    var map = L.map('map').setView([37.8, -96], 4);
                  
                  
                    L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
                      attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors,<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
                      maxZoom: 18,
                      id: 'mapbox.streets',
                      accessToken: 'pk.eyJ1IjoiZW======V6ZTdlb2V5cyJ9.3HqHQ4BMRvSPaYe8ToA7YQ'
                    }).addTo(map);
                  
                  
                    var marker = L.marker([51.5, -0.09]).addTo(map);
                  
                  
                    var myLines = [{
                      "type": "LineString",
                      "properties": {
                        "id": "1"
                      }
                      "coordinates": [
                        [-100, 40],
                        [-105, 45],
                        [-110, 55]
                      ]
                    }, {
                      "type": "LineString",
                      "properties": {
                        "id": "2"
                      }
                      "coordinates": [
                        [-105, 40],
                        [-110, 45],
                        [-115, 55]
                      ]
                    }];
                  
                    var myLayer = L.geoJson().addTo(map);
                    myLayer.addData(myLines);
                  
                  
                    geojson = L.geoJson(myLines, {
                      onEachFeature: onEachFeature
                    }).addTo(map);
                  
                  }
                  
                  
                  
                  function highlightFeature(e) {
                    var layer = e.target;
                  
                    layer
                  
                    layer.setStyle({
                      weight: 25,
                      color: '#ff3300',
                      dashArray: '',
                      fillOpacity: 0.7
                    });
                  
                    if (!L.Browser.ie && !L.Browser.opera) {
                      layer.bringToFront();
                    }
                  }
                  
                  function resetHighlight(e) {
                    geojson.resetStyle(e.target);
                  
                  
                    layer.setStyle({
                      weight: 5,
                      color: '#0000ff',
                      dashArray: '',
                      fillOpacity: 0.7
                    });
                  }
                  
                  
                  function onEachFeature(feature, layer) {
                    layer.on({
                      mouseover: highlightFeature,
                      mouseout: resetHighlight,
                      // click: zoomToFeature
                    });
                  }
                  
                  $('select[name="dropdown"]').change(function() {
                  
                    var item = $(this).val();
                    alert("call the do something function on option " + item);
                    //how to make the chosen line highlighted ??
                  
                  });

                  推荐答案

                  weight 属性不会改变线条边框,它会改变笔画宽度(以像素为单位).您会获得 border 效果,因为您添加了两次线条.这里:

                  weight property is not changing line border, it changes stroke width in pixels. You get border effect because you are adding lines twice. Here:

                  myLayer.addData(myLines);
                  

                  这里:

                  geojson = L.geoJson(myLines, {
                      onEachFeature: onEachFeature
                    }).addTo(map);
                  

                  当悬停多段线时,顶层的样式会发生变化,但由于您添加了两次多段线,因此仍然保留来自下层的多段线.正如 here 所述,默认笔画不透明度为 0.5(设置 <顺便说一句,code>fillOpacity 对于折线来说是多余的,用于更改 stroke-opacity opacity 属性).顶层的折线变成半透明的,这会产生边框效果的错觉.

                  When a polyline is hovered, top layer's style is changed, but because you are adding polylines twice, there still remains a polyline from the lower layer. As it is described here, default stroke opacity is 0.5 (setting fillOpacity is redundant for the polyline by the way, for changing stroke-opacity opacity property is used). Polyline from the top layer becomes semi-transparent, and that makes the illusion of the border effect.

                  因此,您只需删除这一行 myLayer.addData(myLines); 并获得预期的结果.

                  So, you can just remove this line myLayer.addData(myLines); and get the expected result.

                  我制作了一个 fiddle,您的示例已在其中得到纠正.

                  I've made a fiddle, where your example is corrected.

                  这篇关于如何在传单地图上突出显示选定的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何将 Leaflet 地图嵌入到 Reveal.js 演示文稿中? 下一篇:传单 panTo(或 setview)功能?

                  相关文章

                  最新文章

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

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

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

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