Zoom in view.goto not working in EPSG:3826

441
3
01-02-2024 10:44 PM
AbramhumHsu
Emerging Contributor

Hi:

I meet a problem when using view.goto in EPSG:3826;  in EPSG:3857, the view.goto can work well and 

zooming when it move to the new coordinate, but in EPSG:3826, after the screen doing the move action, 

then the zoom action is no react, the value of view.zoom is become -1, the code snippet is as following:

var newCenterPoint = new Point({
  x: new_center_coordinates[0],
  y: new_center_coordinates[1],
  spatialReference: {
  wkid: 3826 // Specify the desired spatial reference WKID
  }
});
esri_goto_option = {
  animate: true,
  duration: 1500,
  spatialReference: {
  wkid: 3826 // Specify the desired spatial reference WKID
  }
};
view.goTo({
  target: newCenterPoint,
  zoom: 15
}, esri_goto_option)
.then(function() {
try {
  console.log("After goTo:", view.zoom);
} catch (error) {
  console.error("Error during goTo:", error);
}
})
.catch(function(error) {
  console.error("Error during goTo:", error);
});

 

is anyone know the problem and how to solve that, thanks a lot.

 

 

 

 

0 Kudos
3 Replies
JoelBennett
MVP Regular Contributor

Since you say goTo works with 3857, this indicates your view.spatialReference is 3857 (Web Mercator).  If that's the case, then using goTo with geometries in anything other than 3857 will not work.  Therefore, you will need to reproject your point from 3826 to 3857 first.  You can do that using the project method of the esri/geometry/projection module.

0 Kudos
AbramhumHsu
Emerging Contributor

Thanks for your reply. Through the way you provided, since the movement of view.goto is correct, only the zoom operation is invalid, then I think this maybe come from the extent information error. Is that possible to set this info to the view.goTo. Thanks a lot.

0 Kudos
JoelBennett
MVP Regular Contributor

I'm not sure what is meant by an extent information error...you may need to give further information on that.

Note that the documentation explains why the zoom value can be -1 in the "Zoom and LODs" section of the MapView documentation, and also in the discussion of the zoom property.  Perhaps that might help you figure out what's going on as well.