<commit_before>// please insert your own MapBox token in place of Jack's version
mapboxgl.accessToken = '<KEY>';

var map1 = new mapboxgl.Map({
  container: 'map1',
  center: [-72.67, 41.76], // Hartford
  zoom: 10,
  style: 'mapbox://styles/mapbox/light-v10'
});

var map2 = new mapboxgl.Map({
  container: 'map2',
  center: [-80.84, 35.22], // Charlotte NC
  zoom: 10,
  style: 'mapbox://styles/mapbox/light-v10',
  attributionControl: false,
});

var hoveredPolygonId1 = null;
var hoveredPolygonId2 = null;
var map1InfoFixed = false;
var map2InfoFixed = false;

// EdBuild elementary school districts 2017
var choroplethLayer = {
    id: 'E_2017',
    source: "src_unielem17",
    "source-layer": "SchoolDistricts_UE_17_data-0hffyk",
    type: "fill",
    paint: {
        "fill-color": {
            property: "pov2017",
            type: "interval",
            stops: [
                [0, "#dff3fe"],
                [.095, "#92DCF0"],
                [.195, "#49B4D6"],
                [.295, "#2586a5"],
                [.395, "#19596d"]
            ],
            "default": "rgba(0, 0, 0, 0)"
        },
        'fill-opacity': [ 'case', ['boolean', ['feature-state', 'hover'], false], 0.8, 1 ]
    }
}

var bordersLayer = {
  id: 'S_2017lines',
  source: "src_unisec17",
  "source-layer": "SchoolDistricts_US_17_data-13ybxj",
  type: "line",
  paint: {
      "line-color": ['case', ['boolean', ['feature-state', 'fixed'], false], 'red', 'white'],
      'line-width': ['case', ['boolean', ['feature-state', 'fixed'], false], 2, 1],
      'line-offset': ['case', ['boolean', ['feature-state', 'fixed'], false], 2, 0],
  }
}


map1.on('load', function() {

  map1.addSource('src_unisec17', {
    'type': 'vector',
    'url': 'mapbox://edbuild.6lt6yxzm'
  });

  // Add polygons (school districts)
  map1.addLayer( choroplethLayer, 'road-label');

  // Add white borders around polygons
  map1.addLayer( bordersLayer )

  map1.on('click', function() {
    map1InfoFixed = !map1InfoFixed;
    if (map1InfoFixed) {
      document.getElementById('info1').style.borderColor = 'red'

      map1.setFeatureState({
        source: 'src_unisec17',
        sourceLayer: 'SchoolDistricts_US_17_data-13ybxj',
        id: hoveredPolygonId1
      }, {fixed: true})

    } else {
      document.getElementById('info1').style.borderColor = 'white'

      map1.setFeatureState({
        source: 'src_unisec17',
        sourceLayer: 'SchoolDistricts_US_17_data-13ybxj',
        id: hoveredPolygonId1
      }, {fixed: false})
    }
  })

  map1.on('mousemove', function(e) {
    var data = map1.queryRenderedFeatures(e.point, {layers: ['S_2017'] })

    if (data[0] && !map1InfoFixed) {

      // Hover opacity change
      if (hoveredPolygonId1) {
        map1.setFeatureState(
          { source: "src_unisec17", sourceLayer: 'SchoolDistricts_US_17_data-13ybxj', id: hoveredPolygonId1 },
          { hover: false }
        );
      }
      hoveredPolygonId1 = data[0].id;
      map1.setFeatureState(
        { source: "src_unisec17", sourceLayer: 'SchoolDistricts_US_17_data-13ybxj', id: hoveredPolygonId1 },
        { hover: true }
      );

      // Update info window only if not fixed
      t = data[0].properties
      document.getElementById('info1').innerHTML = "<strong>" + t.NAME + ", " + t.Postal
        + "</strong><hr>Student Population: <b>" + t.StPp_l17
        + "</b><br>Student Population in Poverty: <b>" + t.StPv_17.toLocaleString()
        + "</b><br>Student Poverty Rate: <b>" + t.StPRL_17 + '</b>'

    } else if (!map1InfoFixed) {
      document.getElementById('info1').innerHTML = 'Hover over the school districts to see data.';
    }
  });
})



map2.on('load', function() {

  map2.addSource('src_unisec17', {
    'type': 'vector',
    'url': 'mapbox://edbuild.6lt6yxzm'
  });

  // Add polygons (school districts)
  map2.addLayer( choroplethLayer, 'road-label');

  // Add white borders around polygons
  map2.addLayer( bordersLayer )

  map2.on('click', function() {
    map2InfoFixed = !map2InfoFixed;
    if (map2InfoFixed) {
      document.getElementById('info2').style.borderColor = 'red'

      map2.setFeatureState({
        source: 'src_unisec17',
        sourceLayer: 'SchoolDistricts_US_17_data-13ybxj',
        id: hoveredPolygonId2
      }, {fixed: true})

    } else {
      document.getElementById('info2').style.borderColor = 'white'

      map2.setFeatureState({
        source: 'src_unisec17',
        sourceLayer: 'SchoolDistricts_US_17_data-13ybxj',
        id: hoveredPolygonId2
      }, {fixed: false})
    }
  })

  map2.on('mousemove', function(e) {
    var data = map2.queryRenderedFeatures(e.point, {layers: ['S_2017'] })

    if (data[0] && !map2InfoFixed) {

      // Hover opacity change
      if (hoveredPolygonId2) {
        map2.setFeatureState(
          { source: "src_unisec17", sourceLayer: 'SchoolDistricts_US_17_data-13ybxj', id: hoveredPolygonId2 },
          { hover: false }
        );
      }
      hoveredPolygonId2 = data[0].id;
      map2.setFeatureState(
        { source: "src_unisec17", sourceLayer: 'SchoolDistricts_US_17_data-13ybxj', id: hoveredPolygonId2 },
        { hover: true }
      );
<commit_msg>fixed more refs to elem layers<commit_after>// please insert your own MapBox token in place of Jack's version
mapboxgl.accessToken = '<KEY>';

var map1 = new mapboxgl.Map({
  container: 'map1',
  center: [-72.67, 41.76], // Hartford
  zoom: 10,
  style: 'mapbox://styles/mapbox/light-v10'
});

var map2 = new mapboxgl.Map({
  container: 'map2',
  center: [-80.84, 35.22], // Charlotte NC
  zoom: 10,
  style: 'mapbox://styles/mapbox/light-v10',
  attributionControl: false,
});

var hoveredPolygonId1 = null;
var hoveredPolygonId2 = null;
var map1InfoFixed = false;
var map2InfoFixed = false;

// EdBuild elementary school districts 2017
var choroplethLayer = {
    id: 'E_2017',
    source: "src_unielem17",
    "source-layer": "SchoolDistricts_UE_17_data-0hffyk",
    type: "fill",
    paint: {
        "fill-color": {
            property: "pov2017",
            type: "interval",
            stops: [
                [0, "#dff3fe"],
                [.095, "#92DCF0"],
                [.195, "#49B4D6"],
                [.295, "#2586a5"],
                [.395, "#19596d"]
            ],
            "default": "rgba(0, 0, 0, 0)"
        },
        'fill-opacity': [ 'case', ['boolean', ['feature-state', 'hover'], false], 0.8, 1 ]
    }
}

var bordersLayer = {
  id: 'E_2017lines',
  source: "src_unielem17",
  "source-layer": "SchoolDistricts_UE_17_data-0hffyk",
  type: "line",
  paint: {
      "line-color": ['case', ['boolean', ['feature-state', 'fixed'], false], 'red', 'white'],
      'line-width': ['case', ['boolean', ['feature-state', 'fixed'], false], 2, 1],
      'line-offset': ['case', ['boolean', ['feature-state', 'fixed'], false], 2, 0],
  }
}


map1.on('load', function() {

  map1.addSource('src_unielem17', {
    'type': 'vector',
    'url': 'mapbox://edbuild.7srzux4k'
  });

  // Add polygons (school districts)
  map1.addLayer( choroplethLayer, 'road-label');

  // Add white borders around polygons
  map1.addLayer( bordersLayer )

  map1.on('click', function() {
    map1InfoFixed = !map1InfoFixed;
    if (map1InfoFixed) {
      document.getElementById('info1').style.borderColor = 'red'

      map1.setFeatureState({
        source: 'src_unielem17',
        sourceLayer: 'SchoolDistricts_US_17_data-13ybxj',
        id: hoveredPolygonId1
      }, {fixed: true})

    } else {
      document.getElementById('info1').style.borderColor = 'white'

      map1.setFeatureState({
        source: 'src_unielem17',
        sourceLayer: 'SchoolDistricts_UE_17_data-0hffyk',
        id: hoveredPolygonId1
      }, {fixed: false})
    }
  })

  map1.on('mousemove', function(e) {
    var data = map1.queryRenderedFeatures(e.point, {layers: ['E_2017'] })

    if (data[0] && !map1InfoFixed) {

      // Hover opacity change
      if (hoveredPolygonId1) {
        map1.setFeatureState(
          { source: "src_unielem17", sourceLayer: 'SchoolDistricts_UE_17_data-0hffyk', id: hoveredPolygonId1 },
          { hover: false }
        );
      }
      hoveredPolygonId1 = data[0].id;
      map1.setFeatureState(
        { source: "src_unielem17", sourceLayer: 'SchoolDistricts_UE_17_data-0hffyk', id: hoveredPolygonId1 },
        { hover: true }
      );

      // Update info window only if not fixed
      t = data[0].properties
      document.getElementById('info1').innerHTML = "<strong>" + t.NAME + ", " + t.Postal
        + "</strong><hr>Student Population: <b>" + t.StPp_l17
        + "</b><br>Student Population in Poverty: <b>" + t.StPv_17.toLocaleString()
        + "</b><br>Student Poverty Rate: <b>" + t.StPRL_17 + '</b>'

    } else if (!map1InfoFixed) {
      document.getElementById('info1').innerHTML = 'Hover over the school districts to see data.';
    }
  });
})



map2.on('load', function() {

  map2.addSource('src_unielem17', {
    'type': 'vector',
    'url': 'mapbox://edbuild.7srzux4k'
  });

  // Add polygons (school districts)
  map2.addLayer( choroplethLayer, 'road-label');

  // Add white borders around polygons
  map2.addLayer( bordersLayer )

  map2.on('click', function() {
    map2InfoFixed = !map2InfoFixed;
    if (map2InfoFixed) {
      document.getElementById('info2').style.borderColor = 'red'

      map2.setFeatureState({
        source: 'src_unielem17',
        sourceLayer: 'SchoolDistricts_UE_17_data-0hffyk',
        id: hoveredPolygonId2
      }, {fixed: true})

    } else {
      document.getElementById('info2').style.borderColor = 'white'

      map2.setFeatureState({
        source: 'src_unielem17',
        sourceLayer: 'SchoolDistricts_UE_17_data-0hffyk',
        id: hoveredPolygonId2
      }, {fixed: false})
    }
  })

  map2.on('mousemove', function(e) {
    var data = map2.queryRenderedFeatures(e.point, {layers: ['E_2017'] })

    if (data[0] && !map2InfoFixed) {

      // Hover opacity change
      if (hoveredPolygonId2) {
        map2.setFeatureState(
          { source: "src_unielem17", sourceLayer: 'SchoolDistricts_UE_17_data-0hffyk', id: hoveredPolygonId2 },
          { hover: false }
        );
      }
      hoveredPolygonId2 = data[0].id;
      map2.setFeatureState(
        { source: "src_unielem17", sourceLayer: 'SchoolDistricts_UE_17_data-0hffyk', id: hoveredPolygonId2 },
        { hover: true }
      );

{'fraction_non_alphanumeric': 0.15882806476484193, 'fraction_numerical': 0.04259830377794911, 'mean_word_length': 2.7844638949671774, 'pattern_counts': {'":': 10, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4372969', 'n_tokens_mistral': 3893, 'n_tokens_neox': 3584, 'n_words': 701}