为什么在某些缩放级别下我的Mapbox GL JS地图中没有显示某些功能?

时间:2019-10-10 04:56:53

标签: mapbox mapbox-gl-js vector-tiles

我是矢量图块和Mapbox GL的新手,正在研究一些入门示例。在下面的示例中,您可以看到某些功能未在初始缩放级别呈现。但是,当您放大时,所有功能都会呈现。据推测,某些功能太小而无法在某些缩放级别进行渲染。假设正在发生这种情况,是否有某种方法可以确定所有要素将呈现的缩放级别?此示例中使用的矢量图块记录在这里:https://gis-server.data.census.gov/arcgis/rest/services/Hosted/VT_2015_140_00_PY_D1/VectorTileServer

    var mapstyle = {
        "version": 8,
        "name": "TractMap",
        "sources": {
            "tractData": {
                type: "vector",
                tiles: [
                  "https://gis-server.data.census.gov/arcgis/rest/services/Hosted/VT_2015_140_00_PY_D1/VectorTileServer/tile/{z}/{y}/{x}.pbf"
                ]
            }
        },
        "layers": [
            {
              id: "tracts",
              type: "fill",
              source: "tractData",
              "source-layer": "CensusTract",
              paint: {
                "fill-opacity": 0.3,
                "fill-color": "purple"
              }
            }
        ]

      }

      var map = new mapboxgl.Map({
        container: "map",
        style: mapstyle, 
        center: {
          lat: 38,
          lng: -95
        },
        zoom: 6
      });


        map.on("click", "tracts", function(e) {
            var coordinates = e.lngLat;

            new mapboxgl.Popup()
            .setLngLat(coordinates)
            .setHTML(
                coordinates
            )
            .addTo(map);
        });
      body {
        margin: 0;
        padding: 0;
      }

      #map {
        position: absolute;
        top: 0;
        bottom: 0;
        width: 100%;
      }
<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v1.2.0/mapbox-gl.css" rel="stylesheet"/>
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v1.2.0/mapbox-gl.js"></script>
<div id="map"></div>

0 个答案:

没有答案