title: How can I assign the contents of a geojson file to a variable in Javascript?
body: <p>The code shown already works, but I want to clean it up. It declares a variable called <strong>placez</strong> which contains information in geojson format for the next part of the code to read and load on a map using filters. However, in reality, the amount of points to be mapped exceeds 50,000 (the example here only shows 2). What I want to know is how I can just load the data coming from a file in the same directory called <strong>placesgj.geojson</strong>, where the 50,000 data entries will be written in geojson format, to the variable <strong>placez</strong> instead of writing them manually there like in the example. The rest of the code is ommited for tidyness, and irrelevant for the functionality. Thanks in advance!</p>
  
  <pre><code>var placez = {
      "type": "FeatureCollection",
      "features": [{
          "type": "Feature",
          "properties": {
              "icon": "theatre"
          },
          "geometry": {
              "type": "Point",
              "coordinates": [-77.038659, 38.931567]
          }
      }, {
          "type": "Feature",
          "properties": {
              "icon": "music"
          },
          "geometry": {
              "type": "Point",
              "coordinates": [-77.007481, 38.876516]
          }
      }]
  };
  map.on('load', function() {
      // Add a GeoJSON source containing place coordinates and information.
      map.addSource("placer", {
          "type": "geojson",
          "data": placez
      });
      placez.features.forEach(function(feature) {
          var symbol = feature.properties['icon'];
          var layerID = 'poi-' + symbol;
  </code></pre>