Unable to display points using Unique Value Renderer

325
2
09-27-2022 04:57 AM
ilyasmd
New Contributor

I am not able to display dots with different colors for specific points using unique value renderer below are the details:

 

I am creating a feature layer and adding it to my map, I call my backend api which provides me with few points with Lat and Long, below is the sample data(omitting few data fields for brevity):

Api data:-

apiData = [{ "EP_A_NUM": 1212,"W_NUM": 2, "W_EXPL_NAME": "ANBU_2", "W_PRIM_HID": "ANBU""SV_LAT_CORD": 240732.6389,"SV_LON_CORD": 380810.2614},

{ "EP_A_NUM": 1313,"W_NUM": 3, "W_EXPL_NAME": "ANBU_3","W_PRIM_HID": "ANBU",   "SV_LAT_CORD":240728.6681,"SV_LON_CORD":380809.5087}]

 
Feature layer creation source code:
 new FeatureLayer({
      source: apiData,
      objectIdField: "EP_A_NUM",
      renderer: {
           type: "unique-value",
           field: "W_EXPL_NAME",
          defaultSymbol: { type: "simple-marker", color: "red" },
          uniqueValueInfos: [ {
          value: "ANBU_2",
          symbol: {
            type: "simple-marker",
            color: "black"
          }]
      },
      fields: [
        { alias: 'W_EXPL_NAME', name: 'W_EXPL_NAME', length: 255, type: 'string' },
        { alias: 'EP_A_NUM', name: 'EP_A_NUM', type: 'integer' },
        { alias: 'W_NUM', name: 'W_NUM', type: 'integer' },
        { alias: 'SV_LAT_CORD', name: 'SV_LAT_CORD', length: 255, type: 'double' },
        { alias: 'SV_LON_CORD', name: 'SV_LON_CORD', length: 255, type: 'double' },
      ]
      geometryType: "point",
      id: 'wells layer',
     spatialReference: { wkid: 4326 },
    });
    view.map.layers.add(wellsLayer); //adding the newly created feature layer to my base map
 
Even if the data contains 'ANBU_2', all the dots are always displayed in red color, whereas one of the point is expected to be displayed in black color.
 
I am not able to understand where is the miss, please help.
Regards,
 
Tags (1)
0 Kudos
2 Replies
JohnGrayson
Esri Regular Contributor

Hard to tell from the partial code provided.  Do you have a simple CodePen (or similar) showing the issue?

0 Kudos
ilyasmd
New Contributor
I have used projection service because of which this issue was being
raised. I was able to fix the issue.
Thanks
0 Kudos