Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8376221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:22:46+00:00 2026-06-09T15:22:46+00:00

I am trying to add some functionality that will zoom the map in/out depending

  • 0

I am trying to add some functionality that will zoom the map in/out depending on the points that are returned from a query. So for example, say we’re zoomed in on the state of Texas. If I execute a query and the service returns back points that are in Texas AND some located in California, I would like the map to then zoom out and then display both California and Texas. I have been looking through the ArcGIS JS API to see how I could implement it but I’m having trouble figuring out what properties and/or methods to use to accomplish this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:22:47+00:00Added an answer on June 9, 2026 at 3:22 pm

    The FeatureSet provided to the QueryTask‘s onComplete callback has the property features that is an array of Graphics.

    The javascript api provides the esri.graphicsExtent(graphics) function that can accept that array of Graphics and calculate their extent. Once the extent has been calculated, map.setExtent(extent) can be used to zoom the map to that extent.

    It should be noted that the documentation for esri.graphicsExtent(...) specifies that ‘If the extent height and width are 0, null is returned.’ This case will occur if the returned Graphics array only has a single point in it, so you’ll want to check for it.

    Here’s an example QueryTask onComplete callback that could be used to zoom the map to the extents of points returned by the query:

    function onQueryComplete(returnedPointFeatureSet){
      var featureSet = returnedPointFeatureSet || {};
      var features = featureSet.features || [];
    
      var extent = esri.graphicsExtent(features); 
      if(!extent && features.length == 1) {
        // esri.getExtent returns null for a single point, so we'll build the extent by hand by subtracting/adding 1 to create x and y min/max values
        var point = features[0];
        extent = new esri.geometry.Extent(point.x - 1, point.y - 1, point.x + 1, point.y + 1, point.spatialReference);
      }
    
      if(extent) {
        // assumes the esri map object is stored in the globally-scoped variable 'map'
        map.setExtent(extent)
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add some functionality to dunst, a small notification system. I've never
I am trying to add some functionality to json processing for some nodes. So
I'm trying to add some simple peer-to-peer connection functionality to an iOS library. Coding
I have a question about some functionality I'm trying to add to my jQuery
I am trying to add some error detection to a script that is used
I'm trying to add some functionality to our code base by using tied scalars.
I'm currently trying to add some testing functionality into our builds, and in order
I'm using Rails 3.1 and trying to add some ajax functionality (using jquery +
I'm trying to add some client-side list grouping functionality into my Rails app. It's
I am trying to add some filters to a gridview that I am working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.