CSVLayer

This device does not support 3D.

View the system requirements for more information.

The CSVLayer allows you to add features from a comma-separated values text file (.csv) or delimited text file (.txt) that include latitude and longitude information. The file is referenced as a hosted file on the web. Because of this, the file must be publically accessible. The file needs to include at least one pair of coordinate fields as these fields are used to locate the features on the map.

This sample shows how add an instance of CSVLayer to a Map in a SceneView. The resulting point features can be queried via the API and then subsequently used as input for other operations.

If CSV files are not on the same domain as your website, a CORS-enabled server or a proxy is required.

How it works

This sample accesses real-time data from the USGS. The USGS site hosting the data is enabled for CORS so all that is needed is to push the server name to the list of corsEnabledServers.

var url = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.csv";
esriConfig.request.corsEnabledServers.push(url);

Next, create a new CSVLayer and set the properties within its constructor. In this specific example, the url to the USGS earthquakes live feed is added in addition to the copyright and popupTemplate properties.

var csvLayer = new CSVLayer({
  url: url,
  copyright: "USGS Earthquakes",
  popupTemplate: template,
  elevationInfo: {
    mode: "on-the-ground"
  }
});

A SimpleRenderer is then set on the layer and the layer added to the map.

// Pass a simple renderer to the layer
csvLayer.renderer = new SimpleRenderer({
  symbol: new PointSymbol3D({
    symbolLayers: [
      new IconSymbol3DLayer({
        material: { color: [238, 69, 0, 0.75] },
        outline: {
          width: 0.5,
          color: "white"
        },
        size: "12px"
      })
    ]
  })
});
// Add the layer to the map
map.add(csvLayer);

Sample search results

TitleSample

There were no match results from your search criteria.