Hi there,
So at JS API version 4.22 and previous versions, you cannot change or set the spatialReference of the view after the view is initialized. If you want to set the spatialReference of the view, you must set it in the constructor.
In your code, you are setting the MapView.spatialReference to Web Mercator, so you'd have to update your code as the following:
const view = new MapView({
container: "viewDiv",
map: map,
scale: 36978595.474472,
center: [-130, 30],
spatialReference: {
wkid: 102100
}
});
The MapView will have the MapImageLayer's spatialReference if you do not set it in the constructor. In that case, you'd have to set the MapView.center in the spatialReference of the view as shown below:
const view = new MapView({
container: "viewDiv",
map: map,
scale: 36978595.474472,
center: {
x: -130,
y: 30,
type: "point",
spatialReference: {
wkid: 4269
}
}
});
At version 4.23, your code will work as is because we are adding a support for switching MapView.spatialReference at runtime.
Hope this helps,
-Undral