【问题标题】:layers control and geojson on mapbox/leafletmapbox/leaflet 上的图层控制和 geojson
【发布时间】:2014-03-20 17:57:41
【问题描述】:

我在混淆the choropleth example

the layes control example

使用带有瓷砖的图层控制,我没有问题,它工作得很好,但我需要使用 geojson,这是我的问题: gejson 层总是在前景和背景上的瓷砖。 但我需要在 layercontrol 中选择“街道”图块时,它会出现在前景中,而 l.geojson 会出现在背景中。 我需要它来显示标签。使用透明度对我的目的不利。 任何解决方案? 这里是部分代码:

  var mapdataviz = L.mapbox.map('map', 'andria.h41061in')
   .setView([39.0981, 16.5619], 8);
 mapdataviz.legendControl.addLegend(document.getElementById('legend-content').innerHTML);


  L.control.layers({
    'city': L.mapbox.tileLayer('andria.cal_com_ief1'),
    'com_geojson': L.geoJson(comData,  {
      style: getStyle,
      onEachFeature: onEachFeature
  }).addTo(mapdataviz),
    'streets': L.mapbox.tileLayer('andria.h41061in')
},
 {
    'streets': L.mapbox.tileLayer('andria.h41061in'),

     'com_geojson': L.geoJson(comData,  {
      style: getStyle,
      onEachFeature: onEachFeature
  }).addTo(mapdataviz),
    'bounds': L.mapbox.tileLayer('andria.cal_conf')
}).addTo(mapdataviz);



  var popup = new L.Popup({ autoPan: false });

  // comData comes from the 'us-states.js' script included above
  var comLayer = L.geoJson(comData,  {
      style: getStyle,
      onEachFeature: onEachFeature
  })

  function getStyle(feature) {
      return {
          weight: 0.7,
          opacity: 0.5,
          color: 'white',
          fillOpacity: 0.8,
          fillColor: getColor(feature.properties.IEF1_2008)
      };
  }

【问题讨论】:

    标签: javascript leaflet mapbox


    【解决方案1】:

    您提到透明度不适合您的目的,但此 MapBox 教程演示了如何将 geoJson 图层放在街道地图图层后面。

    https://www.mapbox.com/blog/neighborhood-mapping-with-dynamic-vector-data-layers/

    有用吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-04
      • 1970-01-01
      相关资源
      最近更新 更多