I try to understand the folowing error :
TypeError: Cannot read properties of null (reading 'targetGeometry')
in my code.
I just define a featurelayer :
Solved! Go to Solution.
I am going to guess that your basemap is a different spatial reference than your service. When you query against the service, the SR will be the original SR of the service. You can. request the geometries to be converted to match your map like this.
function zoomToLayer(layer) {
// create query from layer
const query = layer.createQuery();
// ask for SR to match the View
query.outSpatialReference = view.spatialReference;
return layer.queryExtent(query).then((response) => {
view.goTo(response.extent)
});
}
I am going to guess that your basemap is a different spatial reference than your service. When you query against the service, the SR will be the original SR of the service. You can. request the geometries to be converted to match your map like this.
function zoomToLayer(layer) {
// create query from layer
const query = layer.createQuery();
// ask for SR to match the View
query.outSpatialReference = view.spatialReference;
return layer.queryExtent(query).then((response) => {
view.goTo(response.extent)
});
}
Thank's a lot. It's true I use a local SR for my feature layer
Have a nice day