Not Able to Render Simple Marker Renderer on Feature Layer

323
1
Jump to solution
08-27-2018 03:15 PM
BruceGreen
New Contributor III

Can you please take a look at this demo and let me know why I am not able to add the simple render / Simple Marker to the map for feature layers

require([
    "esri/map",
    "esri/layers/FeatureLayer",
    "esri/renderers/SimpleRenderer",
    "esri/symbols/SimpleMarkerSymbol", 
    "esri/symbols/SimpleLineSymbol", 
    "esri/Color",
    "dojo/domReady!"
  ],
  function(
    Map,
    FeatureLayer,
    SimpleRenderer,
    SimpleMarkerSymbol,
    SimpleLineSymbol,
    Color,
  ) {

    var map = new Map("map", {
      basemap: "streets",
      center: [-82.44109, 35.6122],
      zoom: 17
    });

    var featureLayer = new FeatureLayer("https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0");

    featureLayer.setRenderer( new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 10,
    new Color([0,255,0,0.25])));

    map.addLayer(featureLayer);

  });

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Bruce,

  1. You are trying to set the FeatureLayers renderer to a SimpleMarkerSymbol and not a actual renderer.
  2. You left out the outline portion of the SimpleMarkerSymbol constructor. If you do not want to specify it then you have to pass null at least.
    require([
        "esri/map",
        "esri/layers/FeatureLayer",
        "esri/renderers/SimpleRenderer",
        "esri/symbols/SimpleMarkerSymbol",
        "esri/symbols/SimpleLineSymbol",
        "esri/Color",
        "dojo/domReady!"
      ],
      function(
        Map,
        FeatureLayer,
        SimpleRenderer,
        SimpleMarkerSymbol,
        SimpleLineSymbol,
        Color,
      ) {

        var map = new Map("map", {
          basemap: "streets",
          center: [-82.44109, 35.6122],
          zoom: 17
        });

        var featureLayer = new FeatureLayer("https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0");

        featureLayer.setRenderer(new SimpleRenderer(new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 10, new SimpleLineSymbol(), new Color([0, 255, 0, 0.25]))));

        map.addLayer(featureLayer);

      });

View solution in original post

1 Reply
RobertScheitlin__GISP
MVP Esteemed Contributor

Bruce,

  1. You are trying to set the FeatureLayers renderer to a SimpleMarkerSymbol and not a actual renderer.
  2. You left out the outline portion of the SimpleMarkerSymbol constructor. If you do not want to specify it then you have to pass null at least.
    require([
        "esri/map",
        "esri/layers/FeatureLayer",
        "esri/renderers/SimpleRenderer",
        "esri/symbols/SimpleMarkerSymbol",
        "esri/symbols/SimpleLineSymbol",
        "esri/Color",
        "dojo/domReady!"
      ],
      function(
        Map,
        FeatureLayer,
        SimpleRenderer,
        SimpleMarkerSymbol,
        SimpleLineSymbol,
        Color,
      ) {

        var map = new Map("map", {
          basemap: "streets",
          center: [-82.44109, 35.6122],
          zoom: 17
        });

        var featureLayer = new FeatureLayer("https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0");

        featureLayer.setRenderer(new SimpleRenderer(new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 10, new SimpleLineSymbol(), new Color([0, 255, 0, 0.25]))));

        map.addLayer(featureLayer);

      });