I'm trying to make a simple custom widget that on the button press adds a random point on the map and I'm stuck, this is how my code looks:
import React from 'react';
import { JimuMapView } from 'jimu-arcgis';
import SimpleMarkerSymbol from '@arcgis/core/symbols/SimpleMarkerSymbol';
import { AllWidgetProps } from 'jimu-core';
export interface State{
jimuMapView: JimuMapView | undefined;
}
export default class Widget extends React.PureComponent<AllWidgetProps<any>, State> {
Graphic: any;
Point: any;
GraphicsLayer: any;
constructor(props) {
super(props);
this.state = {
jimuMapView : undefined,
};
}
addPointToMap = () => {
const pointSymbol = new SimpleMarkerSymbol({
type: 'simple-marker',
style: 'square',
color: 'blue',
size: '8px',
outline: {
color: [255, 255, 0],
width: 3,
},
});
const graphicB = new this.Graphic({
geometry: new this.Point({ x: 42.34123, y: 21.12341 }),
symbol: pointSymbol
});
const layer = new this.GraphicsLayer({
graphics: [graphicB]
});
this.state.jimuMapView.view.map.add(layer);
};
render() {
return (
<div>
<button onClick={this.addPointToMap}>Add Point</button>
</div>
);
}
}