AnsweredAssumed Answered

Zoom to Feature from grid button

Question asked by thek04 on Aug 29, 2013
Latest reply on Aug 29, 2013 by kenbuja
I'm trying to zoom to the feature on my map when the user selects a button built into my grid. I have experimented with a couple of different functions to accomplish this.

This makes a button in my grid.
function makeZoomButton(id){//id is objectid         var zBtn = "<div data-dojo-type='dijit.form.Button'><img src='photos/bg_magnify.png'";         zBtn = zBtn + " width='18' height='18'";         zBtn = zBtn + " onClick=\"zoomRow('"+id+"')\"></div>"; //activates zoomRow function         return zBtn;       }


These are two different functions that have tried calling when the button is clicked.

function zoomRow(id){         var grid = dijit.byId('grid');         var clickedWell = grid.getItem(id);         var selectedWell;           dojo.forEach(map.graphics.graphics,function(graphic){           if((graphic.attributes) && graphic.attributes.BUILDING === clickedWell){             selectedWell = graphic;             return;           }         });         var wellExtent = selectedWell.geometry.getExtent();         map.setExtent(wellExtent);         selectionLayer.clear();        // var wellExtent = featureLayer[0].geometry.getExtent().expand(5.0);         //map.setExtent(wellExtent);     }      function zoomRow(id) {         //console.log(id);       dojo.some(wellFeatureLayer.graphic,function(graphic){         if (graphic.attributes.ObjectID.toString() === id) {         console.log(graphic.attributes);           var selectedWell = new esri.Graphic(graphic.geometry).setAttributes(               graphic.attributes);           selectionLayer.add(selectedWell);           var wellExtent = selectedWell.geometry.getExtent().expand(5.0);           map.setExtent(wellExtent);           return true;         }       });     }


Do any of you have any ideas on how I can get this to work?

I attached a screen grab of what the map looks like.

[ATTACH=CONFIG]27089[/ATTACH]

Attachments

Outcomes