title: Geojson Point FeatureCollection insert a variable
body: <p>I create from a MySQL database with PHP an array with coordinates. This array I passed to JavaScript in my HTML website. On this site, I want to display these coordinates as markers in a Mapbox API map.</p>
  <p>It worked everything, except the last step to implement these coordinates in the Geojson FeatureCollection.</p>
  <pre><code>function fccreate() {
    var i;
    var indextt = Object.keys(testtable_array).length;
    for (i = 0; i &lt; indextt; i++) {
        text += '{&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [' + testtable_array[i][1] + ',' + testtable_array[i][2] + ']}},';
    }
  newtext = text.substring(0, text.length - 1);
  addsfa();
  };
  
      
  function addsfa() {
  console.log(newtext);
  map.addSource('mypoints3', {
          'type': 'geojson',
          'data': {
            &quot;type&quot;: &quot;FeatureCollection&quot;,
            &quot;features&quot;: [
                newtext
            ]
            
      }
  });
      
  map.addLayer({
  'id': 'mypoints3',
  'type': 'symbol',
  'source': 'mypoints3',
  'layout': {
  'icon-image': 'custom-marker',
  }
  });
  }
  </code></pre>
  <p>This is the array from PHP:</p>
  <pre><code>testtable_array
  </code></pre>
  <p>The log to the console shows me the right result, because when i enter the result manualy in the geojson the map shows all of the markers.
  Console Log:</p>
  <pre><code>{&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {}, &quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [9.522359619140815,46.85314975627398]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [9.522359619140815,46.85314975627398]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [9.09251953125019,46.973226855658936]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [11.352956040816935,46.479010689522994]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [9.512746582031014,46.84939301152497]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [20.05803762373668,47.77883708313206]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [10.409505615234451,46.86817410754625]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [10.296895751952889,46.80053141630188]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [9.5278527832034,46.857845317683655]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [8.058173337244995,47.247794215485754]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [9.76377244255417,46.436848511271364]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [10.62146641328738,1.658296133484285]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [23.98528433420927,37.41062770063955]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [9.518239746094821,46.8531497562733]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [11.309174279171373,46.41645943261082]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [11.309174279171373,46.41645943261082]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [9.378164062501838,46.91416003055292]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [9.529226074219622,46.8531497562733]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [9.12387896865556,46.982512425911864]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [11.255599004325092,43.76971806046333]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [9.176296671409006,46.83780694910723]}},
  {&quot;type&quot;: &quot;Feature&quot;,&quot;properties&quot;: {},&quot;geometry&quot;: {&quot;type&quot;: &quot;Point&quot;,&quot;coordinates&quot;: [8.361458390095095,48.53379740798499]}}
  </code></pre>
  <p>I'm new to geojson, so maybe I don't know exactly how to paste this variable in the geojson object.</p>
  <p>Any Ideas?</p>
  <p>Thanks very much.</p>