Change default symbology for Add Data widget in Dev

710
6
Jump to solution
07-29-2019 01:27 PM
LeeAllen
Occasional Contributor

I'm looking to change the default symbol when using the "Add Data" widget.  I am using the developer edition, but can't find the code to set the symbol anywhere in the widget code. The default point icon  is way too small. Thanks!

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Lee,

   Here is what you will need to change.

\widgets\AddData\search\AddFromFilePane.js (added Lines 23-26 and 32)

define(["dojo/_base/declare",
"dojo/_base/lang",
"dojo/_base/array",
"dojo/_base/json",
"dojo/on",
"dojo/Deferred",
"dojo/dom-class",
"dijit/Viewport",
"dojo/sniff",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
"dijit/_WidgetsInTemplateMixin",
"dojo/text!./templates/AddFromFilePane.html",
"dojo/i18n!../nls/strings",
"./LayerLoader",
"./util",
"dojo/_base/kernel",
"esri/request",
"esri/layers/FeatureLayer",
"esri/layers/KMLLayer",
"esri/geometry/scaleUtils",
"jimu/dijit/Message",
"esri/symbols/SimpleMarkerSymbol",
"esri/renderers/SimpleRenderer",
"esri/symbols/SimpleLineSymbol",
"esri/Color",
"jimu/dijit/CheckBox"
],
function(declare, lang, array, dojoJson, on, Deferred, domClass, Viewport, sniff,
_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin,template, i18n,
LayerLoader, util, kernel, esriRequest, FeatureLayer, KMLLayer, scaleUtils,
Message, SimpleMarkerSymbol, SimpleRenderer, SimpleLineSymbol, Color) {
...

Same file (added 16 - 21)

...
_addFeatures: function(job,featureCollection) {
//var triggerError = null; triggerError.length;
var fullExtent, layers = [], map = job.map, nLayers = 0;
var loader = new LayerLoader();
if (featureCollection.layers) {
nLayers = featureCollection.layers.length;
}
array.forEach(featureCollection.layers,function(layer) {
var featureLayer = new FeatureLayer(layer, {
id: loader._generateLayerId(),
outFields: ["*"]
});
featureLayer.xtnAddData = true;
if (featureLayer.graphics) {
if(featureLayer.graphics[0].geometry.type === "point"){
featureLayer.renderer = new SimpleRenderer(new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 10,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255,0,0]), 1),
new Color([0,255,0,0.25])));
}
job.numFeatures += featureLayer.graphics.length;
}
...

View solution in original post

6 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Lee,

   Here is what you will need to change.

\widgets\AddData\search\AddFromFilePane.js (added Lines 23-26 and 32)

define(["dojo/_base/declare",
"dojo/_base/lang",
"dojo/_base/array",
"dojo/_base/json",
"dojo/on",
"dojo/Deferred",
"dojo/dom-class",
"dijit/Viewport",
"dojo/sniff",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
"dijit/_WidgetsInTemplateMixin",
"dojo/text!./templates/AddFromFilePane.html",
"dojo/i18n!../nls/strings",
"./LayerLoader",
"./util",
"dojo/_base/kernel",
"esri/request",
"esri/layers/FeatureLayer",
"esri/layers/KMLLayer",
"esri/geometry/scaleUtils",
"jimu/dijit/Message",
"esri/symbols/SimpleMarkerSymbol",
"esri/renderers/SimpleRenderer",
"esri/symbols/SimpleLineSymbol",
"esri/Color",
"jimu/dijit/CheckBox"
],
function(declare, lang, array, dojoJson, on, Deferred, domClass, Viewport, sniff,
_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin,template, i18n,
LayerLoader, util, kernel, esriRequest, FeatureLayer, KMLLayer, scaleUtils,
Message, SimpleMarkerSymbol, SimpleRenderer, SimpleLineSymbol, Color) {
...

Same file (added 16 - 21)

...
_addFeatures: function(job,featureCollection) {
//var triggerError = null; triggerError.length;
var fullExtent, layers = [], map = job.map, nLayers = 0;
var loader = new LayerLoader();
if (featureCollection.layers) {
nLayers = featureCollection.layers.length;
}
array.forEach(featureCollection.layers,function(layer) {
var featureLayer = new FeatureLayer(layer, {
id: loader._generateLayerId(),
outFields: ["*"]
});
featureLayer.xtnAddData = true;
if (featureLayer.graphics) {
if(featureLayer.graphics[0].geometry.type === "point"){
featureLayer.renderer = new SimpleRenderer(new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 10,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255,0,0]), 1),
new Color([0,255,0,0.25])));
}
job.numFeatures += featureLayer.graphics.length;
}
...

View solution in original post

LeeAllen
Occasional Contributor

Thank you Robert, works perfectly!

0 Kudos
ErfanGoharian
New Contributor III

Can you help me (or someone) help me to modify this code in a way that it shows the "polygon" with the red outline and none fill?

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor
            if(featureLayer.graphics[0].geometry.type === "point"){
featureLayer.renderer = new SimpleRenderer(new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 10,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255,0,0]), 1),
new Color([0,255,0,0.25])));
}else if(featureLayer.graphics[0].geometry.type === "polygon"){
featureLayer.renderer = new SimpleRenderer(new SimpleFillSymbol(SimpleFillSymbol.STYLE_NULL,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255,0,0]), 1),
new Color([0,0,0,0])));
}
ErfanGoharian
New Contributor III

THANKS!

Is there a way to also add some coordination (like coordination of shapefile vertices or centroid) of the uploaded shapefile?

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

sorry that is a bit beyond the context of this thread.

0 Kudos