Select to view content in your preferred language

Missing value in AT

479
4
Jump to solution
01-10-2020 11:14 AM
LefterisKoumis
Regular Contributor II

I have this very simple script to define a single pt, and create a feature layer. The featurelayer is displayed on the map and it is listed under the layer list. The infotemplate works too. But the AT just displays the field names but not the values. I know it is something very simple to fix, but I need a fresh pair of eyes to take a look to see what I am missing. THanks.

var layerDefinitionPts = {
          "geometryType": "esriGeometryPoint",
          "fields": [{
              name: "ObjectID",
              type: "esriFieldTypeOID"
            },
            {
              "name": "Field1",
              "type": "esriFieldTypeString"
            },
            {
              "name": "Field2",
              "type": "esriFieldTypeString"
            }
          ]
        }


        var featureCollection = {
          layerDefinition: layerDefinitionPts,
          featureSet: null
        };

        renderer = new SimpleRenderer(symbolPinstart);

        fLayer = new FeatureLayer(featureCollection, {
          id: "Test Layer",
          infoTemplate: infoTemplate
        })


        fLayer.setRenderer(renderer);




        var infoTemplate = new InfoTemplate();
        var point1 = new Point(-118.852, 34.350);
        thegraphic = new Graphic(point1);
        infoTemplate.setContent("My graphic")
        infoTemplate.setTitle("The Graphic")
        thegraphic.setInfoTemplate(infoTemplate)
        thegraphic.setAttributes({
          "ObjectID": 1,
          "field1": 999999,
          "field2": 'LA'
        })

        fLayer.add(thegraphic);
        this.map.addLayer(fLayer)
      },
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

  When you have the "Filter by map extent" on in the AT widget as long as the feature is not in WKID 102100 like you map it will filter out the point even if you see the point on your map. I tested your exact code and observed this behavior. But if I use WebMercatorUtils and make the point web mercator then it works perfectly whether "Filter by map extent" is on or off.

View solution in original post

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

You are using the wrong cAsE in your field names for your graphics attributes. Change the f to F

        thegraphic.setAttributes({
          "ObjectID": 1,
          "Field1": 999999,
          "Field2": 'LA'
        })

and then un-check the filter by map extent in the AT widget.

0 Kudos
LefterisKoumis
Regular Contributor II

Thanks. Robert. Yes, there were the wrong case. But it seems that it was not the only issue, since I still don't get the results.

I just used the Demo widget to test this code.

define(['dojo/_base/declare', 'jimu/BaseWidget',
    "esri/layers/FeatureLayer", 'esri/graphic', "esri/InfoTemplate", 'esri/geometry/Point', 'esri/renderers/SimpleRenderer', "esri/symbols/PictureMarkerSymbol"
  ],
  function (declare, BaseWidget, FeatureLayer, Graphic, InfoTemplate, Point, SimpleRenderer, PictureMarkerSymbol) {
    //To create a widget, you need to derive from BaseWidget.
    return declare([BaseWidget], {
      // DemoWidget code goes here

      //please note that this property is be set by the framework when widget is loaded.
      //templateString: template,

      baseClass: 'jimu-widget-demo',

      postCreate: function () {
        this.inherited(arguments);
        console.log('postCreate');
      },

      startup: function () {
        this.inherited(arguments);
        this.mapIdNode.innerHTML = 'map id:' + this.map.id;
        console.log('startup');
        symbolPinstart = new PictureMarkerSymbol('http://static.arcgis.com/images/Symbols/Animated/ConstantGreenStrobeMarkerSymbol.png', 40, 40);


        var layerDefinitionPts = {
          "geometryType": "esriGeometryPoint",
          "fields": [{
              name: "ObjectID",
              type: "esriFieldTypeOID"
            },
            {
              "name": "Field1",
              "type": "esriFieldTypeString"
            },
            {
              "name": "Field2",
              "type": "esriFieldTypeString"
            }
          ]
        }


        var featureCollection = {
          layerDefinition: layerDefinitionPts,
          featureSet: null
        };

        renderer = new SimpleRenderer(symbolPinstart);

        fLayer = new FeatureLayer(featureCollection, {
          id: "Test Layer",
          infoTemplate: infoTemplate
        })


        fLayer.setRenderer(renderer);




        var infoTemplate = new InfoTemplate();
        var point1 = new Point(-118.852, 34.350);
        thegraphic = new Graphic(point1);
        infoTemplate.setContent("My graphic")
        infoTemplate.setTitle("The Graphic")
        thegraphic.setInfoTemplate(infoTemplate)
        thegraphic.setAttributes({
          "ObjectID": 1,
          "Field1": 999999,
          "Field2": 'LA'
        })

        fLayer.add(thegraphic);
        this.map.addLayer(fLayer)
      },

      onOpen: function () {
        console.log('onOpen');
      },

      onClose: function () {
        console.log('onClose');
      },

      onMinimize: function () {
        console.log('onMinimize');
      },

      onMaximize: function () {
        console.log('onMaximize');
      },

      onSignIn: function (credential) {
        /* jshint unused:false*/
        console.log('onSignIn');
      },

      onSignOut: function () {
        console.log('onSignOut');
      },

      showVertexCount: function (count) {
        this.vertexCount.innerHTML = 'The vertex count is: ' + count;
      }
    });
  });
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

  When you have the "Filter by map extent" on in the AT widget as long as the feature is not in WKID 102100 like you map it will filter out the point even if you see the point on your map. I tested your exact code and observed this behavior. But if I use WebMercatorUtils and make the point web mercator then it works perfectly whether "Filter by map extent" is on or off.

0 Kudos
LefterisKoumis
Regular Contributor II

Thank you.

0 Kudos