Select to view content in your preferred language

How to zoom to graphic layer

3699
6
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 Emeritus

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

6 Replies
RobertScheitlin__GISP
MVP Emeritus

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);
});
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 Esteemed Contributor

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

dkoerner
Emerging Contributor

view.goTo( graphicsLayer.graphics );

ShmuelKatorzaDAO
Occasional Contributor

it working Thanks Javascript 4.21

0 Kudos
AnnaGoldenstein
Emerging Contributor

You saved my day!
Also works in 4.29.

0 Kudos