AnsweredAssumed Answered

Legend & Simple Renderer Error

Question asked by jay.kapalczynski on Dec 27, 2017
Latest reply on Dec 28, 2017 by jay.kapalczynski

I am rendering a point Map Service with a SimpleMarkerSymbol and then a Renderer to set rotation and Color.

This all works fine until I try and add this to a Legend.

 

If I use the below code the Legend Fails.

If I comment it out the and use a general point the Legend works fine.

 

This causes the error:

var marker = new SimpleMarkerSymbol().setPath("M14.5,29 23.5,0 14.5,9 5.5,0z").setAngle(180).setSize(20).setOutline(new SimpleLineSymbol().setColor("#ffffff").setWidth(2));

var renderer = new SimpleRenderer(marker);
  renderer.setRotationInfo({
     field: "HEAD",
     rotationType: "arithmetic"
  });
  renderer.setColorInfo({
     field: "SPEED",
     minDataValue: 0,
     maxDataValue: 150,
     colors: [
        new Color([255,0,0]), new Color([255,0,0]), new Color([34,139,34]), new Color([34,139,34]), new Color([34,139,34]), new Color([34,139,34]), new Color([34,139,34]), new Color([34,139,34])
     ]     
  });
CurrentLoc.setRenderer(renderer);

 

What can I do to keep the SimpleMarkerSymbol and the Renderer?

 

var CurrentLoc = new FeatureLayer("https://xxx/arcgis/rest/services/xxx/MapServer/1", {
   mode: FeatureLayer.MODE_ONDEMAND,
   outFields:["*"],
   infoTemplate: new InfoTemplate("Locations - ${C_ID} - ${ORG}")
});

var marker = new SimpleMarkerSymbol().setPath("M14.5,29 23.5,0 14.5,9 5.5,0z").setAngle(180).setSize(20).setOutline(new SimpleLineSymbol().setColor("#ffffff").setWidth(2));

var renderer = new SimpleRenderer(marker);
  renderer.setRotationInfo({
     field: "HEAD",
     rotationType: "arithmetic"
  });
  renderer.setColorInfo({
     field: "SPEED",
     minDataValue: 0,
     maxDataValue: 150,
     colors: [
        new Color([255,0,0]), new Color([255,0,0]), new Color([34,139,34]), new Color([34,139,34]), new Color([34,139,34]), new Color([34,139,34]), new Color([34,139,34]), new Color([34,139,34])
     ]     
  });
CurrentLoc.setRenderer(renderer);



//add the legend
map.on("layers-add-result", function (evt) {
   var layerInfo = arrayUtils.map(evt.layers, function (layer, index) {
       return {layer:layer.layer, title:layer.layer.name};
   });     
   if (layerInfo.length > 0) {
     var legendDijit = new Legend({
        map: map,
        layerInfos: layerInfo,
     }, "legend");
     legendDijit.startup();
   }
});

 

Is it because of this:  If so how can I create an Arrow Symbol and set it to a specific angle via an attribute in the data?

 

var marker = new SimpleMarkerSymbol().setPath("M14.5,29 23.5,0 14.5,9 5.5,0z").setAngle(180).setSize(20).setOutline(new SimpleLineSymbol().setColor("#ffffff").setWidth(2));

Outcomes