INFO17

FeatureLayer centerAt

Discussion created by INFO17 on Jul 2, 2013
Hi all,

Someone can help me please.

I build a widget with combobox.
When I select combobox lign, I want to display and centerAt to this object(point) with my toggleLayer function.
This works well, but if I comment alert("Ok");, it don't work....!?


toggleLayer: function(item){

        //--return intial feature extent 
  this.map.setExtent(featureLayer.fullExtent);           
   
  //--apply a definition expression to the layer to only display objects of the selected theme
        var query = "ETIQUETTE='${name}'";

        //--display point
        featureLayer.setScaleRange(0,0); 
               
        featureLayer.setDefinitionExpression(esri.substitute({
         name:  item
        }, query));
      
        //--zoom to point          
        var geom;
   
  var query2 = new esri.tasks.Query();
        query2.where = "1=1 AND ETIQUETTE='"+item+"'";
        query2.returnGeometry = true;
        query2.outSpatialReference = this.map.spatialReference;
        query2.orderByFields = ["ID_BUREAU ASC"]; 
   
        featureLayer.selectFeatures(query2, esri.layers.FeatureLayer.SELECTION_NEW);   
 
        dojo.connect(featureLayer, "onSelectionComplete", function(results) {
                geom = results[0].geometry;     
 });
 
 alert("Ok");
   
 this.map.centerAt(new esri.geometry.Point(geom));
},



Thank you.


[Math - French developper]

Outcomes