Select to view content in your preferred language

Highlight OnRowClick Feature on Map?

899
3
01-17-2012 01:18 PM
EmilyLaMunyon
Deactivated User
Hello,

I have an application that displays the results of an Identify Task in a datagrid. I then utilize the OnRowClick Handler to zoom to the feature. I would like the feature that is being zoomed to from each row to be highlighted on the map. Any help would be greatly apprciated!! 🙂



 function onRowClickHandler(evt){ 


  
  }  if (searchType == "Surveys") { 
   var clickedTaxLotId = grid3.getItem(evt.rowIndex).DOCUMENT_N; 
   var selectedTaxLot; 
   dojo.forEach(map.graphics.graphics,function(graphic){ 
     if((graphic.attributes) && graphic.attributes.DOCUMENT_N === clickedTaxLotId){ 
    selectedTaxLot = graphic; 
    //added this part to build infotemplate
     map.infoWindow.setTitle(graphic.getTitle()); 
     map.infoWindow.setContent(graphic.getContent());
                            return; 
     } 
        }); 
  
   if ( selectedTaxLot.geometry.declaredClass == 'esri.geometry.Point' ) {
   map.centerAndZoom(taxLotExtent, 11)
                                      var sp = map.toScreen(selectedTaxLot.geometry);
   map.infoWindow.show(selectedTaxLot.geometry, map.getInfoWindowAnchor(sp));
   } else {
   //alert("Polygon");
   var taxLotExtent = selectedTaxLot.geometry.getExtent(); 
   var screenpoint = map.toScreen(selectedTaxLot.geometry.getExtent().getCenter());
   var mappoint = map.toMap(screenpoint);
    map.setExtent(taxLotExtent,true);
   map.infoWindow.show(taxLotExtent.getCenter(), map.getInfoWindowAnchor(screenpoint));
   }
  
  
 } else if (searchType == "PointName") { 
   var clickedTaxLotId = grid4.getItem(evt.rowIndex).POINT_NAME; 
   var selectedTaxLot; 
   var highlightSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([25,50,225,0.3])); 
   dojo.forEach(map.graphics.graphics,function(graphic){ 
     if((graphic.attributes) && graphic.attributes.POINT_NAME === clickedTaxLotId){ 
    selectedTaxLot = graphic; 
    //added this part to build infotemplate
     map.infoWindow.setTitle(graphic.getTitle()); 
     map.infoWindow.setContent(graphic.getContent());
    return; 
     } 
        }); 
  
   if ( selectedTaxLot.geometry.declaredClass == 'esri.geometry.Point' ) {
   map.centerAndZoom(selectedTaxLot.geometry, 11)
   var sp = map.toScreen(selectedTaxLot.geometry);
   map.infoWindow.show(selectedTaxLot.geometry, map.getInfoWindowAnchor(sp));
   } else {
   //alert("Polygon");
   var taxLotExtent = selectedTaxLot.geometry.getExtent(); 
   var screenpoint = map.toScreen(selectedTaxLot.geometry.getExtent().getCenter());
   var mappoint = map.toMap(screenpoint);
    //map.centerAt(mappoint);
    map.centerAndZoom(selectedTaxLot.geometry,15);
   
   map.infoWindow.show(taxLotExtent.getCenter(), map.getInfoWindowAnchor(screenpoint));
   }
                                    }
                                 }

]
0 Kudos
3 Replies
KellyHutchins
Esri Notable Contributor
One way to do this would be to add the graphic to the map with a 'highlight symbol' applied. Here's a sample that shows this approach:

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/query_hover.ht...
0 Kudos
DeanSeales
Emerging Contributor
Emily,
would you be so kind and share your code for this application?

I have been struggling with displaying the contents of the pop in a datagrid.

Any assistance would be greatly appreciated.

Thank you!
0 Kudos
EmilyLaMunyon
Deactivated User
Hi Dean,

Sure, here is my code so far (attached). Please understand that while it is funtional, it is still a work in progress and is pretty messy. I am working on cleaning it up as I get better at coding. Please feel free to ask me any questions you may have.

Thanks!
0 Kudos