CSVLayer
Note: Support for 3D on mobile devices may vary, 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.
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 = {
type: "simple", // autocasts as new SimpleRenderer()
symbol: {
type: "point-3d", // autocasts as new PointSymbol3D()
symbolLayers: [{
type: "icon", // autocasts as 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);