I am trying to implement a drag and drop functionality for a polygon sketch and getting this error while doing so:
[esri.core.Accessor] Accessor#set Assigning an instance of 'esri.geometry.SpatialReference' which is not a subclass of 'esri.geometry.SpatialReference'
I am able to achieve the functionality but my console gets flooded with this error.
Here is what i wrote about spatial reference:
Sample application please.
I should note, this can happen if you are using two different versions of the API for some reason, or mixing npm with the CDN. This can also happen in some monorepo use cases as well.
Hello,
I have updated the question by including more sample code. Please check it once and see if there is a solution for resolving this error.
Thanks in advance.
This is a bit silly, but from your code it looks like you need to replace the way you defined your polygon geometry from this:
const polygon: any = {
type: "polygon",
rings: vertices,
spatialReference: view2.spatialReference
};
to this:
const polygon: any = {
type: "polygon",
rings: vertices,
spatialReference: {wkid:3857} // for example, it can be another CRS that you want to use
};
It seems that the API handles casting the object better than getting a SpatialRefernce object