Select to view content in your preferred language

How to restore default symbology for dynamic layer ArcGISDynamicMapServiceLayer

1753
6
Jump to solution
11-09-2016 09:50 PM
PitersonPaulgek
Deactivated User

Probably, simple question that I cannot find answer from API reference:

After applying custom symbology

https://developers.arcgis.com/javascript/3/jsapi/arcgisdynamicmapservicelayer.html#setlayerdefinitio...

app.anyLayer.setLayerDrawingOptions(optionsArray);

how to restore default symbology for it?

0 Kudos
1 Solution

Accepted Solutions
thejuskambi
Frequent Contributor

You can restore the original symbology / renderer etc by setting the LayerDrawingOptions to null.

var layerOptions = [];
layerOptions[subLayerId] = null;

dynamiclayer.setLayerDrawingOptions(layerOptions);

View solution in original post

6 Replies
RobertScheitlin__GISP
MVP Emeritus

Piterson,

  You keep a copy of the original renderer and then restore it, or you remove the layer from the map and re-add it. There is no restore render option.

0 Kudos
PitersonPaulgek
Deactivated User

Robert,

Thank you for response.

Please provide example code how to "keep a copy of the original renderer".

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Piterson,

  Sure here is  a sample that shows that:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Feature Layer Only Map</title>
    <link rel="stylesheet" href="http://js.arcgis.com/3.13/esri/css/esri.css">
    <style>
      html, body, #map {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
    <script src="http://js.arcgis.com/3.13/"></script>
    <script>
      var oRenderer;
      require([
        "dojo/dom-construct",
        "esri/map",
        "esri/layers/FeatureLayer",
        "esri/geometry/Extent",
        "esri/InfoTemplate",
        "dojo/domReady!"
      ], function(
          domConstruct,
          Map,
          FeatureLayer,
          Extent,
          InfoTemplate
        ) {
          var bounds = new Extent({
            "xmin":-16045622,
            "ymin":-811556,
            "xmax":7297718,
            "ymax":11142818,
            "spatialReference":{"wkid":102100}
          });

          var map = new Map("map", {
            extent: bounds
          });

          var url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer/2";

          var template = new InfoTemplate("World Regions", "Region: ${REGION}");

          var fl = new FeatureLayer(url, {
            id: "world-regions",
            infoTemplate: template
          });
          fl.on('load', function(evt){
            console.info(evt.target.renderer);
            oRenderer = evt.target.renderer;
          });

          map.addLayer(fl);
        }
      );
    </script>
  </head>
  <body>
    <div id="map"></div>
  </body>
</html>
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
PitersonPaulgek
Deactivated User

Robert, Many Thanks!!

0 Kudos
thejuskambi
Frequent Contributor

You can restore the original symbology / renderer etc by setting the LayerDrawingOptions to null.

var layerOptions = [];
layerOptions[subLayerId] = null;

dynamiclayer.setLayerDrawingOptions(layerOptions);
PitersonPaulgek
Deactivated User

Thank you thejus! I will try.

0 Kudos