view.goTo

2661
4
Jump to solution
10-30-2019 04:51 AM
kawishabbas
Occasional Contributor

Hi

View.goTo is not working any suggestion..?

  let point = {
                type: "point",
                x: i.geometry.x,
                y: i.geometry.y,
                spatialReference: { wkid: 32642}
              }
                                            
   let  g = new Graphic({
                         geometry: point,
                         symbol: {
                                  type: "simple-marker",
                                  size: 7,
                                  color: [227, 241, 18],
                                  outline: null
                                  }
                             })
    view.goTo({
             target: point,
             zoom: 12
          }); 
    view.graphics.add(g)
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Output of point object is....

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Kawish,

   You have to project the geometry to the same spatial reference as the map.

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Kawish,

  Though a Graphic can autocast the geometry object you are feeding it. The GoTo is expecting an actual Geometry class and not a Object class.

So you can change to:

view.goTo({
  target: g,
  zoom: 12
}); 

since the goTo function can take a graphic, geometry, etc

kawishabbas
Occasional Contributor

Robert 

Its not working properly and  map goes to wrong position while graphic update/add on exact location

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Kawish,

   You have to project the geometry to the same spatial reference as the map.

kawishabbas
Occasional Contributor

Thank You Robert

0 Kudos