Select to view content in your preferred language

Zoom to specific layer extent

2116
10
06-28-2010 02:11 AM
LukeEvans
Emerging Contributor
Hi,

I need to be able to zoom to the extent of a specific layer.  Zooming to the initial/full extent of a Map Server isn't a problem.  The issue is trying to get the extent for a specific layer under this.

Here for example.  How would I retrieve the extent values?  The only layer specific information I can seem to retrieve is from a LayerInfo object, which doesn't contain the details I need

Thanks

Luke
Tags (2)
0 Kudos
10 Replies
RobertScheitlin__GISP
MVP Emeritus
0 Kudos
DavideRodomonti1
Deactivated User
Hi Luke did u solve this problem?...I have the same too...
Thanks,
David
0 Kudos
LukeEvans
Emerging Contributor
Luke,

   You need to use the LayerDetails

http://resources.esri.com/help/9.3/arcgisserver/apis/flex/apiref/com/esri/ags/layers/LayerDetails.ht...


Thanks for your help.  I've got it working now

Hi Luke did u solve this problem?...I have the same too...
Thanks,
David


Here's just some little example hacked up code I got going just to test it out

  public function zoomToLayerExtent(layerID:int, layer:ArcGISDynamicMapServiceLayer):void
  {
   var responder:IResponder = new Responder(layerDetailsResult, layerDetailsFault);
   layer.getDetails(layerID,responder);
  }

  public function layerDetailsResult(layerDetails:LayerDetails):void
  {
   // Handle LayerDetails here.  Zoom to layer extent from layerDetails.extent
  }

  public function layerDetailsFault():void
  {
                       // Error code
  }
0 Kudos
DavideRodomonti1
Deactivated User
Thanks for your help.  I've got it working now



Here's just some little example hacked up code I got going just to test it out

  public function zoomToLayerExtent(layerID:int, layer:ArcGISDynamicMapServiceLayer):void
  {
   var responder:IResponder = new Responder(layerDetailsResult, layerDetailsFault);
   layer.getDetails(layerID,responder);
  }

  public function layerDetailsResult(layerDetails:LayerDetails):void
  {
   // Handle LayerDetails here.  Zoom to layer extent from layerDetails.extent
  }

  public function layerDetailsFault():void
  {
                       // Error code
  }


Thanks Luke, it works....but I dont get what I want...
Cause in my code I first apply a layerDefinitions and I want that map.extent is the new layer.extent but I get the original layer extent... :((( :
     
var dLayer:ArcGISDynamicMapServiceLayer = map.getLayer("Map") as ArcGISDynamicMapServiceLayer;
         var layerDefs:Array = new Array();
         var layerStr:String = new String();    
         layerDefs[0] = "c_edificio='" + txtMessage.text + "'";
         layerDefs[1] = "";
         layerDefs[2] = ""; 
         layerDefs[3] = "";         
         dLayer.layerDefinitions = layerDefs;
         dLayer.refresh();
         zoomToLayerExtent(0,dLayer); 
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
David,

   The rest service directory that the LayerDetails is getting the extent info from does not know about any layer definitions that you have applied (as those are client side).

To do what you are trying to do you need to query the map service using your same layer definition query and then get the graphics extent, like this

var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features);
                        if (graphicsExtent)
                        {
                            map.extent = graphicsExtent;
                        }
0 Kudos
DavideRodomonti1
Deactivated User
David,

   The rest service directory that the LayerDetails is getting the extent info from does not know about any layer definitions that you have applied (as those are client side).

To do what you are trying to do you need to query the map service using your same layer definition query and then get the graphics extent, like this

var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features);
                        if (graphicsExtent)
                        {
                            map.extent = graphicsExtent;
                        }


Hi Robert, yes u are right I tried with this and it works well!!!
I populated list of value I want to use to make the definition query...but I wish I could use an intelligent text box who show me the values that match in part with what I m writing...
Thank u so much Robert!!
David
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
David,

   Google "Yahoo Astra"
0 Kudos
DavideRodomonti1
Deactivated User
David,

   Google "Yahoo Astra"


Thanks Robert, I saw similar things in a link posted in some discussion of sample flex viewer...now I cant find some sample anymore..

David
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
David,

   Yahoo's site has several examples. There has only been one or two threads on this in the last year or more and none of them deal exactly with what you are doing.
0 Kudos