Hi all,
I have the following error when i use the goTo method in a view: Accessor#set Assigning an instance of 'esri.geometry.SpatialReference' which is not a subclass of 'esri.geometry.SpatialReference'.
#The goTo functionality works correct though... The part of the code is here:
The service is not publicly available. The spatial reference is the same for the layer, the view and the query. It does correctly go to the queried features and the behavior is as expected but the console log has this error for all the returned features.
Any feedback would be very helpful!
Thanks in advance.
Regards,
Michael
Hi Michail Marinakis,
I have same error, in some other context. Please see my question.
Have you found a solution?
Michael
Hi Michael,
i checked your issue and it is not exactly the same. In our issue, the error message was mentioning that the instance SpatialReference is not a subclass of SpatialReference which doesn't make a lot of sense.
In your issue, the error message is:"'SceneLayer' which is not a subclass of 'esri.layers.FeatureLayer'" and that makes sense. If you see here, the inheritance is SceneLayer -> Layer -> Accessor.
I guess that somewhere there is a reference to a layer that should be treated as a feature layer and not instantiated as a SceneLayer. That's why the API is complaining.
In any case, we fix our issue by auto-casting. In our case we create the point and the spatial reference via auto-casting, e.g. something like that
Hope this helps! Good luck!
I was receiving this same error today using 4.18, and tracked it down the following problem: I had code like this:
define(["esri/Geometry/Extent", "esri/layers/FeatureLayer", "esri/tasks/support/Query"], function(Extent, FeatureLayer, Query) {
//etc
});
However, notice the capital "G" in "Geometry". Unfortunately, it took me quite awhile to notice that, but once I fixed it to the following, the error messages stopped:
define(["esri/geometry/Extent", "esri/layers/FeatureLayer", "esri/tasks/support/Query"], function(Extent, FeatureLayer, Query) {
//etc
});
This doesn't appear to be the problem you're having, but if, like me, somebody else ends up here because they're getting this message, hopefully this might help.
One other thing to mention, I notice your code has:
query.outSpatialReference = new SpatialReference(31370);
However, the documentation doesn't indicate support for passing a number in the constructor. I have observed that 4.16 - 4.18 do allow this in practice, but considering the date of the original post, maybe you were using an older version of the API that had a problem with it? To be consistent with the documentation, though, it would be best to pass an object with the wkid property set:
query.outSpatialReference = new SpatialReference({wkid:31370});