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.
Solved! Go to Solution.
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);
});
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);
});
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.
graphicExtent is expecting an array of graphics, not a GraphicsLayer.
view.goTo( graphicsLayer.graphics );
it working Thanks Javascript 4.21
You saved my day!
Also works in 4.29.