Mapbox-gl-js-template

HTML

<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.46.0/mapbox-gl.js"></script>
<link rel="stylesheet" href="https://api.tiles.mapbox.com/mapbox-gl-js/v0.46.0/mapbox-gl.css">
  <div id='map'></div>

CSS

html, body{
    height: 100%;
}

#map {
  height: 100%;
  width: 100%;
}

JavaScript

mapboxgl.accessToken = 'pk.eyJ1IjoiYXNzYWZuIiwiYSI6ImNqMnJvY2F0YjAwYmQzMnFwN3BhZGxweHcifQ.AkTCCxKL5OSBxYHLBsKIzA';

var map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v9',
    center: [-120.109, 39.3],
    minZoom: 2,
    zoom: 12
});

var lines = {
    "type": "FeatureCollection",
    "features": [
      {
          "type": "Feature",
          "id": 1,
          "properties": {
              "COUNTY": "theatre"
          },
          "geometry": {
              "type": "LineString",
              "coordinates": [
                [-120.109, 39.3],
                [-116.709, 39.369]
              ]
          }
      },
      {
          "type": "Feature",
          "id": 2,
          "properties": {
              "COUNTY": "theatre"
          },
          "geometry": {
              "type": "LineString",
              "coordinates": [
                [-116.709, 39.369],
                [-92.709, 39.369],
              ]
          }
      }
    ]
};

map.on('load', function() {
    // Add the source to query. In this example we're using
    // county polygons uploaded as vector tiles
    map.addSource('counties', {
        "type": "geojson",
        "data": lines
    });

    map.addLayer({
      type: 'line',
      source: 'counties',
      id: 'counties',
      paint: {
        'line-color': [
          'match',
          [ 'string', [ 'feature-state', 'color' ], 'none' ],
          'selected', 'red',
          'none', 'black',
          'black'
        ],
        'line-width': 3.0
      },
      layout: {
        'line-cap': 'round',
        'line-join': 'round'
      }
    });

    map.on('click', 'counties', function(e) {
        var county = e.features[0].properties.COUNTY;
				var relatedFeatures = map.querySourceFeatures('counties', {
            filter: ['in', 'COUNTY', county]
        });
        console.log(relatedFeatures);
        relatedFeatures.forEach(f => {
        	const s = {source: 'counties', id:...