Im trying to zoom to the extent of a couple of graphics that are on the map. None of the methods that worked for api 3.x are available in v4. Im hoping someone knows alternatives.


graphicsUtils is marked as coming soon. This has the graphicsExtent(graphics) method that i could use.

I have tried the method


but I need to specify the zoom myself. Which is not helpful. I want it to dynamically calculate bounds/extent and zoom to fit the graphics.

2 Answers 2


You can try something like this:

var fullExtent = null;
for (var i = 0; i < features.length; i++) {
    if (!fullExtent)
        fullExtent = features[i].geometry.extent.clone();
mapView.goTo(fullExtent).then(function () {
    if (!mapView.extent.contains(fullExtent))
        mapView.zoom -= 1;

That is my ugly solution for now because the goTo() function doesn't have a fit parameter. BTW, You can also try using something like fullExtent.expand(1.5) instead of adjusting the zoom level.


The view.goTo() method seems to work fine for zooming to an array of graphics. As Orlando has shown, you can zoom out one level to create a cushion.

view.goTo(graphics).then(function () {
    view.zoom = view.zoom - 1;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.