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'
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
});
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);
}
Do you have a simple CodePen showing the issue?
Hey,
Do you have an exmaple of the ESRI JS API import in CodePen?
Thank you,