I'm trying to create a custom layer widget which would be open and look something like this:
I created the above example using the calcite component example provided in the resources folder and then put it in my > client > your-extensions > widgets folder. I modified the widget.tsx code to reflect my target layers. I just don't know where or with what code to add the layers URL/feature layer info that would correspond to each checkbox.
import { React, type AllWidgetProps } from 'jimu-core'
import { type IMConfig } from '../config'
/**
* Use this way, the @esri/calcite-components-react code will be compiled into widget entry, which makes widget size large.
* `import { CalciteButton, CalciteIcon, CalciteSlider } from '@esri/calcite-components-react'`
* So, we should use the below way.
*/
import { CalciteButton, CalciteIcon, CalciteSlider } from 'calcite-components'
const Widget = (props: AllWidgetProps<IMConfig>) => {
const text = props.config.text
const [sliderValue, setSliderValue] = React.useState(50)
return (
<div className="widget-calcite jimu-widget m-2">
<div className="App">
<h5> Ancillary Layer Selector</h5>
<calcite-label layout="inline">
<calcite-checkbox></calcite-checkbox>
Parks
</calcite-label>
<calcite-label layout="inline">
<calcite-checkbox></calcite-checkbox>
Transit Stops
</calcite-label>
<calcite-label layout="inline">
<calcite-checkbox></calcite-checkbox>
Grocery Stores
</calcite-label>
<calcite-label layout="inline">
<calcite-checkbox></calcite-checkbox>
Libraries
</calcite-label>
<calcite-label layout="inline">
<calcite-checkbox></calcite-checkbox>
Unfavorable POIs
</calcite-label>
<CalciteIcon icon/>
</div>
</div>
)
}
export default Widget
Any advice or a different approach would be helpful. Thanks in advance.
GRMapper
There are a couple of ways to approach this:
Thanks Tim. I’m going to unpack your response and thanks for the kickstart. I’ll have a look at the react approach as well. Very helpful.