SnapShot class

The SnapShot class allows you to create a web map and feature collection layers from one or more graphic arrays. Each new layer can inherit properties from a source layer such as its pop-up, rendering, and scale range.

AMD Module Require

require(["jimu/dijit/SnapShot"], function(SnapShot) { /* code goes here */ });

Constructor

new SnapShot(params)

Creates a new SnapShot dijit.

Parameters:

<Object> params—Required. Parameters for the SnapShot dijit.

params properties:

<Object> appConfig—Required. The applicaton configuration from the parent Web AppBuilder application.

<Object> map—Required. The map instance from the parent Web AppBuilder application.

Example:

require(['jimu/dijit/SnapShot'], function(SnapShot) {
      var snapShot = new SnapShot(this.appConfig, this.map);
      ...
    });

Methods

createSnapShots(options)

Creates a feature collection for each graphics array and adds it to a new web map. All items are created in a new folder under the current user's content and can be shared with the appropriate groups, organization, or the public.

Parameters:

<Object> options—Required. The user-defined properties and data used to create the snapshot.

params properties:

<Array> data—Required. Array of data objects that describe the feature collections to create.

<String> name—Optional. Default name value.

Default:

<Default>

"<map item title>_<time>"

<Object> shareWith—Optional. Expected to follow Share item (as item owner) properties.

Default:

<Default>

{
  "everyone": false,
  "org": false,
  "groups": ""
}

<Object> folderOptions—Optional. Applicable item Common Parameters for a CreateFolder call.

Default:

<Default>

{
  "name": <name>,
  "title": <name>,
  "description": <name>
}

<String> mapTitle—Optional. User-provided map title.

Default:

<Default>


"mapTitle": <name>

<Object> mapExtent—Optional. User-provided extent object.

Default:

<Default>

"mapExtent": <Current Map Extent>

Example:

require(['jimu/dijit/SnapShot'], function(SnapShot) {
          //Get layer from web map
          var mapLayer = this.getFeatureLayerFromMap();
          //Create the snapshot class
          var snapShot = new SnapShot(this.appConfig, this.map);
          //Create the snapshot
          snapshot.createSnapShot({
            name: "Hurricane Madison (Day 1)",
            data: [          
              {
                name: mapLayer.name, 
                graphics: mapLayer.graphics, 
                renderer: mapLayer.renderer, 
                infoTemplate: mapLayer.infoTemplate, 
                fields: mapLayer.fields, 
                typeIdField: mapLayer.typeIdField, 
                types: mapLayer.types, 
                minScale: mapLayer.minScale, 
                maxScale: mapLayer.maxScale, 
                tags: ["Hurricane Madison"], 
                description: "Detailed view of Hurricane Madison on Day 1", 
                visibileOnStartup: true, 
                appendTimeStamp: true, 
              }
            ],
            shareWith: {
              everyone: false, 
              org: false, 
              groups: "c862c5643df74db68553f31136f5d1b3"
            },
            folderOptions: {
              name: "HurricaneMadison", 
              title: " HurricaneMadison", 
              description: "Data and maps for hurricane Madison"
            }
          });
          ...
    });

Options

Option Object

{
  name: String,
  data: [<Data Object>],
  shareWith: Object,
  folderOptions: Object,
  mapExtent: Object,
  mapTitle: String
}

{
  name: “Hurricane Madison (Day 1)”,
  data: [<Data Object>]
}

Data Object

{
  graphics: [Object],
  renderer: Object,
  infoTemplate: Object,
  fields: Array,
  tags: Array,
  description: String,
  name: String,
  visibleOnStartup: Boolean,
  appendTimeStamp: Boolean,
  typeIdField: String,
  types: Array,
  minScale: Integer,
  maxScale: Integer
}

{
  graphics: featureLayer.graphics,
  renderer: featureLayer.renderer,
  infoTemplate: featureLayer.infoTemplate,
  fields: featureLayer.fields,
  tags: [“Hurricane Madison”],
  description: “Snapshot of Hurricane Madison on 6/12/17”,
  name: “Hurricane Madison Points”,
  visibleOnStartup: false,
  appendTimeStamp: true,
  typeIdField: featureLayer.typeIdField,
  types: featureLayer.types,
  minScale: featureLayer.minScale,
  maxScale: featureLayer.maxScale
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.