Dehighlighting a highlighted feature

3101
5
Jump to solution
06-25-2015 05:33 AM
SatyanarayanaNarmala
New Contributor III

hi all,

i have highlighted a point based on selection using

SelectedFindDeceasedName.setSymbol(highlightSymbol);

how can u dehighlight the same before highlighting the other point feature

thanks,

satya

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Satya,

  So if the symbol321 is the NORMAL symbol then you need to apply that symbol to each other graphic.

        dojo.forEach(map.graphics.graphics,function(graphic){
          //deselect all graphics first
          SelectedFindDeceasedName.setSymbol(symbol321);
          if((graphic.attributes) && graphic.attributes.FID === FindDeceasedName){
            SelectedFindDeceasedName = graphic;
            //Apply the highlight symbol to only the one that matches
            SelectedFindDeceasedName.setSymbol(highlightSymbol);
            return;
          }
        });

View solution in original post

5 Replies
RobertScheitlin__GISP
MVP Emeritus

Satya,

   You just use setSymbol again on that feature again and apply the normal symbol. I would normally set a global var for the current selected symbol that way you know which one to apply the normal symbol to.

TimWitt2
MVP Alum

Satya,

check out this example: ArcGIS API for JavaScript Sandbox

they use a mouse-over event, first they clear all graphics and then they add a highlight graphic.

Tim

SatyanarayanaNarmala
New Contributor III

Hi,

this is my code

initially set the symbol

symbol321 = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 0.1, null, new Color([255, 255, 0, 0.5]));

function onRowClickHandler(evt){ 

       

  var FindDeceasedName = grid.getItem(evt.rowIndex).FID; 

 

        var SelectedFindDeceasedName; 

       

        dojo.forEach(map.graphics.graphics,function(graphic){ 

       

          if((graphic.attributes) && graphic.attributes.FID === FindDeceasedName){ 

         

            SelectedFindDeceasedName = graphic; 

            SelectedFindDeceasedName.setSymbol(symbol321);   

            return; 

          } 

         

        }); 

       

        var FindDeceasedNameExtent = SelectedFindDeceasedName.geometry;

       

        SelectedFindDeceasedName.setSymbol(highlightSymbol);

   

  var factor = 0.1; 

  var extent; 

   

        extent = new esri.geometry.Extent({ "xmin": FindDeceasedNameExtent.x - factor, "ymin": FindDeceasedNameExtent.y - factor, "xmax": FindDeceasedNameExtent.x + factor, "ymax": FindDeceasedNameExtent.y + factor, "spatialReference": { "wkid": 3857} }); 

  map.setExtent(extent); 

   

      } 

still previously highlighted is not cleared.

Regds,

Satya

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Satya,

  So if the symbol321 is the NORMAL symbol then you need to apply that symbol to each other graphic.

        dojo.forEach(map.graphics.graphics,function(graphic){
          //deselect all graphics first
          SelectedFindDeceasedName.setSymbol(symbol321);
          if((graphic.attributes) && graphic.attributes.FID === FindDeceasedName){
            SelectedFindDeceasedName = graphic;
            //Apply the highlight symbol to only the one that matches
            SelectedFindDeceasedName.setSymbol(highlightSymbol);
            return;
          }
        });
SatyanarayanaNarmala
New Contributor III

Hi Robert,

  1. dojo.forEach(map.graphics.graphics,function(graphic){ 
  2.           //deselect all graphics first 
  3.           graphic.setSymbol(symbol321); 
  4.           if((graphic.attributes) && graphic.attributes.FID === FindDeceasedName){ 
  5.             SelectedFindDeceasedName = graphic; 
  6.             //Apply the highlight symbol to only the one that matches 
  7.             SelectedFindDeceasedName.setSymbol(highlightSymbol); 
  8.             return; 
  9.           } 
  10.         }); 

Thanks,

Satya.

0 Kudos