AnsweredAssumed Answered

Generating featurelayer from esriJson

Question asked by JM1984 on Jun 20, 2017
Latest reply on Jun 20, 2017 by thejus.kambi

Hello, I am having some problems with the esriJson format, I tried replacing the javascript new SimpleRenderer with esriJson but I get an error:

 

"Uncaught (in promise) TypeError: f.getSymbol is not a function"

 

However when i create it with javascript it works. I actually want to create a PictureMarker with esrijson but i thought i would start simple with a cricle. Please help me locate the problem.

 

var template = {
   title: "<font color='black'>Basestation ID: {idBasestation}</font>",
   content: "Hello: {idBasestationData}",
};

 

var graphics = [
{
   geometry: new Point({
      x: -100,
      y: 38
   }),
   attributes: {
      idBasestationData : 3,
      idBasestation: 3000,
   }
}];

 

var lyr = new FeatureLayer({
   fields: [
   {
      name: "idBasestationData",
      alias: "idBasestationData",
      type: "oid"
   }, {
      name: "idBasestation",
      alias: "idBasestation",
      type: "integer"
   }],
   objectIdField: "ObjectID",
   geometryType: "point",
   spatialReference: { wkid: 4326 },
   source: graphics,
   renderer:
   {
      type: "simple",
      symbol:
      {
         type: "esriSMS",
         style: "esriSMSCircle",
         color: [255,0,0,255],
         size: 5,
         angle: 0,
         xoffset: 0,
         yoffset: 0,
         outline:
         {
            color: [0,0,0,255],
            width: 1
         },
      },
      label: "",
      description: "",
      rotationType: "geographic",
      rotationExpression: 0

   },
   popupTemplate: template
});

/* If I use the code below it works

renderer : new SimpleRenderer({
   symbol: new PictureMarkerSymbol({
      url: "https://webapps-cdn.esri.com/Apps/MegaMenu/img/logo.jpg",
      width: "30px",
      height: "30px"
   })
})
*/

 

map.add(lyr);
});

Outcomes