Setting Attributes Dynamically for graphics used in Service Area

447
2
03-27-2010 07:53 AM
AdamPfister
Esri Contributor
Is there a way to dynamically set the attributes used in the features for Service Areas?  I've used the Service Area example from the javascript samples to try and modify.  See below.

Thanks,
Adam

 function mapClickHandler(evt){
      map.graphics.clear(); //clear existing graphics    
      //define the symbology used to display the results and input point
      var pointSymbol =  new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_DIAMOND, 20,
            new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
            new dojo.Color([88,116,152]), 2),
            new dojo.Color([88,116,152,0.45]));      
      var inPoint = new esri.geometry.Point(evt.mapPoint.x,evt.mapPoint.y,map.spatialReference);
      
      //this doesn't work
      var location = new esri.Graphic(inPoint, pointSymbol, {
     "FreightCost": 3.50
    }, null);

      map.graphics.add(location);
      var features = [];
      features.push(location);
      var facilities = new esri.tasks.FeatureSet();
      facilities.features = features;
      params.facilities = facilities;

      //solve ...
}
0 Kudos
2 Replies
KellyHutchins
Esri Frequent Contributor
Hi Adam,

I think you've already recieved an answer to this question, but I thought I'd post the details here in case others run into this issue. You need to modify the name of the attribute to Attr_<Your Field Name>, which in your case would be "Attr_FreightCost".

Take a look at the 'Facility properties' section of the following help topic for details on the attribute input fields.

http://help.esri.com/en/arcgisdesktop/10.0/help/index.html#/Service_area_analysis/004700000048000000...

You will also need to make sure that the cadidate field names for the Attr_FreightCost attribute contains the Attr_FreightCost value.
0 Kudos
AdamPfister
Esri Contributor
Kelly,

Yes it was making sure the "Candidate Field" value was filled in.  Thanks for checking.

Adam
0 Kudos