Unable to use sketch class on Jimumapview

209
0
12-03-2022 04:13 AM
StephanoWamlyoma
New Contributor

i am getting this error when try to add a sketch on jimuMapview widget,
error: "[esri.support.LayersMixin] #add() The item being added is not a Layer or a Promise that resolves to a Layer."".

Aim: to enable a sketch tool on the map(jimuMapview) so as i can drawn a shape and do ascreen shot and save, so now i can not implement sketch with jimuMapview class.

here is my codes:

/ @jsx jsx / import { React, AllWidgetProps, jsx } from "jimu-core"; import { JimuMapViewComponent, JimuMapView } from "jimu-arcgis"; import Sketch from "@arcgis/core/widgets/Sketch"; import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer"; export default class Widget extends React.PureComponent<AllWidgetProps<any>, any> {

state = { jimuMapView: null, }; activeViewChangeHandler = (jmv: JimuMapView) => { let graphicsLayer = new GraphicsLayer(); if (jmv) { this.setState({ jimuMapView: jmv }); jmv.view.when(() => { const sketch = new Sketch({ layer: graphicsLayer, view: jmv.view, creationMode: "update", }); jmv.view.ui.add(sketch, "top-right"); // this.state.jimuMapView.view.map.add(this.graphicsLayer); }); }}; render() { return <div className="widget-starter jimu-widget"> {/ *
ADD **/} {this.props.hasOwnProperty("useMapWidgetIds") && this.props.useMapWidgetIds && this.props.useMapWidgetIds[0] && ( <JimuMapViewComponent useMapWidgetId={this.props.useMapWidgetIds?.[0]} onActiveViewChange={this.activeViewChangeHandler} /> ) } </div>; } }

Tags (1)
0 Replies