Highlight an identify result on the map

642
3
11-18-2010 06:19 AM
JamesB
by
New Contributor
I understand arcgis desktop has a feature whereby you can click on a element and it will be highlighted on the map. We're trying to do something similar ... a user does an Identify search and then gets a set of results, and later can click on one to get a highlight appearing on the map.

It looks like the class "IdentifyResult" has a "feature" attribute which is a "Graphic" type
So we should be able to do something like
map.graphics.add(result.feature)
no?

But I'm having problems getting this to produce anything ... anyone have any ideas?
Thanks,
James
0 Kudos
3 Replies
timgogl
New Contributor II
sure, i have done something like this. here is the function that shows the feature.

  function showFeature(r) {
   // r is the results set from the identifyResults
   var symbol;
   var feature;
      
   clearFeatures();//clear any old symbols
   
   for(var i=0;i<r.length;i++){// loop thru the list of items adding a symbol for each item
    feature=r.feature;
    if(feature.geometry.type == 'point'){
     symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_DIAMOND, 14,
           new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
            new dojo.Color(MARK_OUTLINE_COLOR), 2), new dojo.Color(MARK_FILL_COLOR));
    }else{
     symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NULL, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color(MARK_OUTLINE_COLOR), 2));
    }
    feature.setSymbol(symbol);
    map.graphics.add(feature);
   }
   curDisplayGraphic = feature;// set the geometry & attributes to the selected feature. (or the last item in a group of items)
  }


so, if the user clicks on an item, and there are more then 1 result returned from the identify, it will loop thru and either put a symbol on the item if it is a point, or outline/fill a polygon.
0 Kudos
JamesB
by
New Contributor
Thank you, have managed to work in a solution now 🙂
0 Kudos
timgogl
New Contributor II
um.... im not sure i understand what you mean.

in my code when an identify happens, the call back is triggered, inside the callback i run this function.

it takes the results (r) and loops thru them, then based on the item feature, puts a symbol for each feature in the result set on the map.

did i miss read your original question? i thought that is what you wanted.
0 Kudos