Get layer names and data/tables from map widget to load into custom widget

260
0
07-27-2022 10:38 AM
Jackson_CountyMissouri
New Contributor III

Hello, I'm new-ish to experience builder and am coming up blank trying to figure out how to do something that might be pretty basic.

I have a custom widget I'm trying to make to export the data from a feature layer in the map to a .csv file. But before I do that I'm first just trying to figure out how to access the layers in the map widget from my custom widget. I've looked over the EB docs and some examples but they aren't very useful.

To start I have the code below. I have a pull-down which I want to get the layer names from the map widget. I don't want to have to hard-code the layer sources or anything because the layers in the map might change.

import { React, AllWidgetProps, jsx } from 'jimu-core';
import { JimuMapViewComponent, JimuMapView } from 'jimu-arcgis';
import { IMConfig } from '../config';

function tableToCSV()
{
	// will do something here
}


export default class Widget extends React.PureComponent<AllWidgetProps<IMConfig>, state> {
	
	constructor (props)
	{
		super(props)
		this.state = {
			value1: "test1",
			value2: "test2",
			value3: "test3"
		}
	}

	render ()
	{
		return (
			<br/>
			<div style={{ padding:10;margin:10;}}>
				<label for="toolSelect"><b>Select Layer to Download CSV:</b></label><br/>
				<select id="toolSelect" class="btn btn-primary dropdown-toggle">
					<option>{this.state.value1}</option>
					<option>{this.state.value2}</option>
					<option>{this.state.value3}</option>
				</select>
				<br/>
				<br/>
				<br/>
				<button onClick={tableToCSV}>Download CSV</button>
			</div>
		);
  }
}

I want to load the layer names where the value1: "test1" (and so on) lines are. How do I do that?

Also, for my next step after that,  if I want to convert the data in the layer table to a csv, will I need to load a Table widget into my map, or can I just use a feature layer?

0 Kudos
0 Replies