Commit 95e562da authored by Amy Stamile's avatar Amy Stamile
Browse files

Latest demo code.

parent b9f0c4b2
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -71,23 +71,23 @@ function getItemCollection(name) {
  }
}

function getStacItems(name) {
  return getItemCollection(name).then(result => {
    console.log("STAC Item Collection: ");
    console.log(result);
    var items = [];
    console.log(result.links.length);
      for (let i = 0; i < result.links.length; i++) {
        if (result.links[i].rel == 'item') {
          fetch(result.links[i].href)
            .then(response => response.json())
            .then(data => items.push(data))
        }
      }
      console.log(items);
      return items;
  });
}
// function getStacItems(name) {
//   return getItemCollection(name).then(result => {
//     console.log("STAC Item Collection: ");
//     console.log(result);
//     var items = [];
//     console.log(result.links.length);
//       for (let i = 0; i < result.links.length; i++) {
//         if (result.links[i].rel == 'item') {
//           fetch(result.links[i].href)
//             .then(response => response.json())
//             .then(data => items.push(data))
//         }
//       }
//       console.log(items);
//       return items;
//   });
// }


export{ getStacItems };
export{ getItemCollection };
+20 −10
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ import "proj4leaflet";

import AstroProj from "./AstroProj";
import LayerCollection from "./LayerCollection";
import { getStacItems } from "./ApiJsonCollection";
import { getItemCollection } from "./ApiJsonCollection";
import { MY_JSON_MAPS } from "./layers";

/**
@@ -121,15 +121,25 @@ export default L.Map.AstroMap = L.Map.extend({
  loadFootprintLayer: function(name) {
    var footprintLayer = L.geoJSON().addTo(this);

    getStacItems(name).then(footprints => {

      // wait 3 seconds to fully grab array of stac items
      setTimeout(() => {
        for (let i = 0; i < footprints.length; i++) {
          footprintLayer.addData(footprints[i]);
    getItemCollection(name).then(result => {
        console.log("STAC Item Collection: ");
        console.log(result);
          for (let i = 0; i < result.links.length; i++) {
            if (result.links[i].rel == 'item') {
              fetch(result.links[i].href)
                .then(response => response.json())
                .then(data => footprintLayer.addData(data))
            }
          }
      }, 3000);
    })
      });
    //   // wait 3 seconds to fully grab array of stac items
    //   setTimeout(() => {
    //     console.log(footprints.length)
    //     for (let i = 0; i < footprints.length; i++) {
    //       footprintLayer.addData(footprints[i]);
    //     }
    //   }, 3000);
    // })
  },

  /**