How to zoom to graphic layer

1618
3
Jump to solution
12-15-2016 12:27 PM
by Anonymous User
Not applicable

Hi all,

I am trying to zoom to a graphic layer but I have no success,\

var GraphicsBuffer = new GraphicsLayer();
                GraphicsBuffer.id = 'GraphicsBuffer';


var extent = esri.graphicsExtent(GraphicsBuffer);
                                map.setExtent(extent, true);

any help is welcome.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Alex,

   You should not get in the horrible habit of mixing AMD and Legacy coding styles.

require(["esri/graphicsUtils"], function(graphicsUtils) {
  var GraphicsBuffer = new GraphicsLayer({
    id: 'GraphicsBuffer'
  });
  var extent = graphicsUtils.graphicsExtent(GraphicsBuffer.graphics);
  map.setExtent(extent, true);
});

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Alex,

   You should not get in the horrible habit of mixing AMD and Legacy coding styles.

require(["esri/graphicsUtils"], function(graphicsUtils) {
  var GraphicsBuffer = new GraphicsLayer({
    id: 'GraphicsBuffer'
  });
  var extent = graphicsUtils.graphicsExtent(GraphicsBuffer.graphics);
  map.setExtent(extent, true);
});

View solution in original post

by Anonymous User
Not applicable

Robert,

You are right about AMD/legacy. I am reviewing my code right now to check if any other legacy code is left.

Thanks for the help on this one too.

0 Kudos
KenBuja
MVP Honored Contributor

graphicExtent is expecting an array of graphics, not a GraphicsLayer.