Zooming to ArcGIS JavaScript API graphic feature, but not to full extent?

المشرف العام

Administrator
طاقم الإدارة
I feel there must be an easy solution for this because I can't be the only one who's had this need before.

I have a Python based geoprocessing service that gets called in my web app. The web app takes a few input parameters, and zooms to a returned buffered section of cable that meets the criteria. This all works really great.

I'm using the following code to zoom to the returned graphic feature:

map.setExtent(graphicsUtils.graphicsExtent(map.graphics.graphics));But, I really don't want the map to zoom this close to the graphic:



I'd prefer something like this:



Now, I've tried something hacky that works, but I don't really like it:

map.setExtent(graphicsUtils.graphicsExtent(map.graphics.graphics));setTimeout(function () { var level = map.getLevel() map.setLevel(level - 2)}, 1000);You actually see it zoom to the graphic extent, and then zoom out.

I'm hoping someone more experienced with the API can provide a solution, or put me on the right track. Would the best way be to do some calculation on the graphic extent object before setting setExtent()?



أكثر...
 
أعلى