Zoom to By rectangle

892
6
Jump to solution
03-06-2023 10:57 PM
Vakhtang_Zubiashvili
Occasional Contributor III

Hi folks,

 

Is there any working code to draw rectangle and zoom to place? Or i gave to start working on it now? 😀

 

 

0 Kudos
1 Solution

Accepted Solutions
Sage_Wall
Esri Contributor

Sure, at a really high level all you need to do is create a new rectangle graphic and then zoom to it with the view.goTo() method.  I created a codepen ( https://codepen.io/sagewall/pen/dyqZVwd ) that shows one approach of doing this with the sketch widget.  It would be a bit more work, but you could create your own button and use the SketchViewModel to draw the rectangle. Creating your own button would give you more control over the styling of your button.

View solution in original post

6 Replies
Sage_Wall
Esri Contributor

Hi @Vakhtang_Zubiashvili ,

I may be misinterpreting your question, but if you hold down the shift key, then click down and hold the button on your mouse, you should be able to draw a rectangle and when you release the button you will be zoomed to that extent.

Vakhtang_Zubiashvili
Occasional Contributor III

@Sage_Wall Thanks a lot, i missed this part in documentation ❤️

0 Kudos
Vakhtang_Zubiashvili
Occasional Contributor III

Is there any other way to click e.g. on button and after draw rectangle and zoom?

0 Kudos
Vakhtang_Zubiashvili
Occasional Contributor III

Is there any other way to click e.g. on button and after draw rectangle and zoom?

0 Kudos
Sage_Wall
Esri Contributor

Sure, at a really high level all you need to do is create a new rectangle graphic and then zoom to it with the view.goTo() method.  I created a codepen ( https://codepen.io/sagewall/pen/dyqZVwd ) that shows one approach of doing this with the sketch widget.  It would be a bit more work, but you could create your own button and use the SketchViewModel to draw the rectangle. Creating your own button would give you more control over the styling of your button.

Vakhtang_Zubiashvili
Occasional Contributor III

Thank you very much @Sage_Wall , now i will make some changes for myself 😉

0 Kudos