goToOverride with Bookmarks

390
2
Jump to solution
05-03-2023 08:36 AM
Leonidas
New Contributor II

I am trying to wrap my head around how I can use the goToOverride with Bookmarks to slow down the change of view with the duration option.  I can get the scale work which is part of the target set of options. 

It looks like any time goTo is used, a target is required and the options are optional which is my hang up.  How do I specify in the goToOverride to use the selected book mark as the target.  

Code below does not work with line 8 being the issue.  I have tried a few different options here.  How do I reference the selected bookmark?

Thanks!

const bookmarks = new Bookmarks({
          view: view,  
          // goToOvverideTesting not working
          goToOverride: function (view, options){
            console.log(options);
            // options.easing= "ease-in";
            options.duration= 2000;           
            return view.goTo(bookmarks.viewpoint, options);            
          },
          // goToOverrideTesting
          bookmarks:[
            new Bookmark({
              name: "Carp",
              viewpoint: {
                targetGeometry: {
                  type: "extent",
                  spatialReference: {
                    wkid: 102100
                  },
                  xmin: -8467000,
                  ymin: 5674000,
                  xmax: -8461000,
                  ymax: 5677700
                }
              }
            }),
            new Bookmark({
              name: "Kemptville",
              viewpoint: {
                targetGeometry: {
                  type: "extent",
                  spatialReference: {
                    wkid: 102100
                  },
                  xmin: -8438000,
                  ymin: 5608300,
                  xmax: -8405300,
                  ymax: 5635200
                }
              }
            }),
          ]
        });

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AnneFitz
Esri Regular Contributor

Try something like this for the goToOverride: 

goToOverride: (view, goToParams) => {
  const options = {
     duration: 2000
  };
  return view.goTo(goToParams.target, options);
},

The original target will be stored in that 2nd parameter of the goToOverride function.

View solution in original post

0 Kudos
2 Replies
AnneFitz
Esri Regular Contributor

Try something like this for the goToOverride: 

goToOverride: (view, goToParams) => {
  const options = {
     duration: 2000
  };
  return view.goTo(goToParams.target, options);
},

The original target will be stored in that 2nd parameter of the goToOverride function.

0 Kudos
Leonidas
New Contributor II

Thanks Anne, this worked!

0 Kudos