Accessor#set Assigning an instance of 'esri.Graphic' which is not a subclass of 'esri.Graphic'

505
4
04-12-2021 06:23 PM
LaurynasGedminas2
Occasional Contributor
import Graphic from '@arcgis/core/Graphic';
import Point from '@arcgis/core/geometry/Point';
import SimpleMarkerSymbol from '@arcgis/core/symbols/SimpleMarkerSymbol';

 

	componentDidUpdate (props) {
		console.log(props);
		const Point ={
			type: "point",
			longitude: props.data[23],
			latitude: props.data[24]
			 
		};
		const simpleMarkerSymbol = {
			type: "simple-marker",
			color: [46, 204, 113 ],  // Green
			outline: {
			color: [255, 255, 255], // white
			width: 1
			}
		};
		const pointGraphic = new Graphic({
			geometry: Point,
			symbol: simpleMarkerSymbol
			//attributes: attributes,
			//popupTemplate: popupTemplate
		});
		/*
		const graphicB = new Graphic({  // graphic with point geometry
			geometry: new Point({
				type: "point",
				longitude: props.data[23],
				latitude: props.data[24]
			}), // set geometry here
			symbol: new SimpleMarkerSymbol({
				type: "simple-marker",
				color: [46, 204, 113 ],  // Green
				outline: {
					color: [255, 255, 255], // white
					width: 1}
				})
				// set symbol here
		});
		*/

		this.props.view.graphics.add(pointGraphic);

		
	}

 

 

error:

Accessor#set Assigning an instance of 'esri.Graphic' which is not a subclass of 'esri.Graphic'

 

 

Tags (1)
0 Kudos
4 Replies
JohnGrayson
Esri Regular Contributor

You import the class Point and then redefine this variable in your code to an object instance.  Try these changes:

 

const myPoint ={
  type: "point",
  longitude: props.data[23],
  latitude: props.data[24]	 
};

const pointGraphic = new Graphic({
  geometry: myPoint,
  symbol: simpleMarkerSymbol  
});

 

 

 

0 Kudos
LaurynasGedminas2
Occasional Contributor

Still gettign the error:

[esri.core.Accessor] Accessor#set Assigning an instance of 'esri.Graphic' which is not a subclass of 'esri.Graphic'

	componentDidUpdate (props) {
		console.log(props);
		const myPoint ={
			type: "point",
			longitude: props.data[24],
			latitude: props.data[23]
			 
		};
		const simpleMarkerSymbol = {
			type: "simple-marker",
			color: [46, 204, 113 ],  // Green
			outline: {
			color: [255, 255, 255], // white
			width: 1
			}
		};
		const pointGraphic = new Graphic({
			geometry: myPoint,
			symbol: simpleMarkerSymbol
			//attributes: attributes,
			//popupTemplate: popupTemplate
		});
		/*
		const graphicB = new Graphic({  // graphic with point geometry
			geometry: new Point({
				type: "point",
				longitude: props.data[23],
				latitude: props.data[24]
			}), // set geometry here
			symbol: new SimpleMarkerSymbol({
				type: "simple-marker",
				color: [46, 204, 113 ],  // Green
				outline: {
					color: [255, 255, 255], // white
					width: 1}
				})
		});
		*/
		
		this.props.view.graphics.add(pointGraphic);
		
	}

 

0 Kudos
JohnGrayson
Esri Regular Contributor

Do you have a simple CodePen showing the issue?

0 Kudos
LaurynasGedminas2
Occasional Contributor

Hey,

Do you have an exmaple of the ESRI JS API import in CodePen?

Thank you,

0 Kudos