ArcGIS API for JavaScript – Displaying In-Memory GeoJSON

arcgis-maps-sdk-javascriptazuregeojson

Right now I have a GeoJSON hosted on Azure so I can download it by URL like so:

const geojsonLayer = new GeoJSONLayer({
 url: "www.url.from.azure.com,
 copyright: "USGS Earthquakes",
 popupTemplate: template
});

But it is quite big (~30 MB) and takes a while to load, so what I am trying to do is host it on Azure as a .zip file, download it, and then parse it into JSON. What I then want to do is feed it into the GeoJSONLayer so I can then display it. Is there anyway to do this?

I already have the download a zip file, unzip and parse as a JSON function ready so it would just be displaying the parsed JSON object.

Best Answer

You can take advantage of createObjectURL to create a URL object that you can set the GeoJSONLayer.url parameter to.

  function createGeoJSONURL(yourgeojson) {
    return URL.createObjectURL(
      new Blob([JSON.stringify(yourgeojson)], {
        type: "application/json"
      })
    );
  }