I have gis data which i can access over Arcgis Rest with Arcgis js api and i have non-gis data which i get from different db.I want to mashup this two like in this link

http://www.cartographicperspectives.org/index.php/journal/article/viewFile/cp76-hunt/1311 (look page 6)

this is my code

DemMin = new Number; DemMax = new Number; 
jQuery("#testMenu").click(function () {
// sample -- > is feature layer already defined somewhere else in the code

    $.getJSON('/home/getresult', null,  // this returns array of json like [{grid_no= 2,avg_heat=3},{grid_no= 1,avg_heat=5}]
function (data) {
   $.each(data, function (i, C) {

       if (C.avg_heat < DemMin) { DemMin = C.avg_heat; }
       if (C.avg_heat > DemMax) { DemMax = C.avg_heat; }

       $.each(sample.graphics, function (k, G) {

           if (G.attributes.GRID_NO == C.grid_no) {
               G.attributes.AVG_HEAT = C.avg_heat;  // (1) adding featurlayer.graphics.attributes not featurelayer field i know ::)),  look for (2)
               alert(G.attributes.AVG_HEAT);   // this alert works and shows G.attributes.AVG_HEAT which i added
               return false;

   var testrenderer = new SimpleRenderer(new SimpleFillSymbol().setOutline(new SimpleLineSymbol().setWidth(0.5)));

   testrenderer.setColorInfo({//set classification values and symbology color information
       field: "AVG_HEAT",   // (2)  This my adding, why i getting error ,this is field not in feature layer i know:))
       minDataValue: DemMin,
       maxDataValue: DemMax,
       colors: [
           new Color([255, 0, 0]),
           new Color([255, 255, 0])]




the error i get of course

-- esri.layers.FeatureLayer: unable to find 'AVG_HEAT' field in the layer 'fields' information "feature_layer_url"

is there anyway to this code working?

Note : I know Arcgis js api "Gas price data by state mashup" sample is similar mashup but please stay on this sample !!


you need to make sure the fields[] array associated with your featureLayer includes any field you'd like to render on.

an alternative example, in which the entire featureLayer is created from a featureCollection, and information about the schema of the table is supplied via a layerDefinition, can be found here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.