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!
Solved! Go to Solution.
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;
}
...
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;
}
...
Thank you Robert, works perfectly!
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?
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])));
}
THANKS!
Is there a way to also add some coordination (like coordination of shapefile vertices or centroid) of the uploaded shapefile?
sorry that is a bit beyond the context of this thread.
I am trying this out, but am getting this when I add a test file to the widget to load:
There was an issue.
I.set is not a function
Has anyone encountered this? Currently looking for a solution. Will let you know if I find one.
Edit: This is with WAB 2.20 and a GEOjson file which was not present in 2.12. I will work with AddFromFilePane.js from 2.12 and see if I can get that to work.
Hey there -- wondering if you've found a solution to this? I'm currently running into the same issue. Looking at the possibility of using PictureMarker instead of SimpleSymbol but would prefer a symbol over a picture.
@RobertScheitlin__GISP Curious if you might have encountered the above error before?
EDIT: Was able to figure out the e.set is not a function error. It had to do with the order in which libraries were defined at the top of the script.
Prior order (failure): CheckBox, SimpleMarkerSymbol, SimpleRenderer, SimpleLineSymbol, Color.
Current Order (succes): SimpleMarkerSymbol, SimpleRenderer, SimpleLineSymbol, Color, CheckBox