Hi Folks,
Problem: I have built a custom widget that creates a pre-defined custom graphic and adds to map, I need to be able to create a layer for this in the layer list (shows up in the layer list widget) such as "Custom Graphic", and be able to consume this in a geoprocessing widget (by selecting a layer from the map).
Issue
just wondering if anyone has done something similar,
I have modified the draw widget so that it creates custom shapes with different javascript algorithms,
so far it has been pretty simple to draw the custom shapes, but I want to add them to the map (Layer List), but have them be their separate entity, currently the draw result shows this (image below)
and in any geoprocessing widget, the draw_results will not load in the drop down by a geoprocessing tool (see such parameter below)
therefore I am unable to actually consume that polygon graphic in a geoprocessing tool,
in the image below is shows I want the custom graphic to show up
please, any help would be much appreciated. If someone can crack this, I will send them a Six Pack of beer, or maple syrup from Canada.
Thanks,
Solved! Go to Solution.
seems that the other post is pretty accurate, as Robert Scheitlin pointed out, the query results used the following javascript to add the custom layer.
_createQueryResultLayer: function(){
var resultLayer = null;
var symbol = symbolJsonUtils.fromJson(this.currentAttrs.config.resultsSymbol);
var renderer = new SimpleRenderer(symbol);
if (this.cbxOperational.checked) {
//new a feature layer
var layerInfo = lang.clone(this.currentAttrs.layerInfo);
var queryName = this._getBestQueryName(this.currentAttrs.config.name || '');
//override layerInfo
layerInfo.name = queryName;
//ImageServiceLayer doesn't have drawingInfo
if(!layerInfo.drawingInfo){
layerInfo.drawingInfo = {};
}
layerInfo.drawingInfo.renderer = renderer.toJson();
layerInfo.drawingInfo.transparency = 0;
layerInfo.minScale = 0;
layerInfo.maxScale = 0;
layerInfo.effectiveMinScale = 0;
layerInfo.effectiveMaxScale = 0;
layerInfo.defaultVisibility = true;
//only keep necessary fields
var necessaryFieldNames = this._getOutputFields();
layerInfo.fields = array.filter(layerInfo.fields, lang.hitch(this, function(fieldInfo){
return necessaryFieldNames.indexOf(fieldInfo.name) >= 0;
}));
var featureCollection = {
layerDefinition: layerInfo,
featureSet: null
};
resultLayer = new FeatureLayer(featureCollection);
} else {
//use graphics layer
this._resetAndAddTempResultLayer();
resultLayer = this.tempResultLayer;
}
this.currentAttrs.query.resultLayer = resultLayer;
this.queryResults.resultLayer = resultLayer;
//set renderer
resultLayer.setRenderer(renderer);
return resultLayer;
},
this could be a possible answer, still looking for suggestions though, while I test this
seems that the other post is pretty accurate, as Robert Scheitlin pointed out, the query results used the following javascript to add the custom layer.
_createQueryResultLayer: function(){
var resultLayer = null;
var symbol = symbolJsonUtils.fromJson(this.currentAttrs.config.resultsSymbol);
var renderer = new SimpleRenderer(symbol);
if (this.cbxOperational.checked) {
//new a feature layer
var layerInfo = lang.clone(this.currentAttrs.layerInfo);
var queryName = this._getBestQueryName(this.currentAttrs.config.name || '');
//override layerInfo
layerInfo.name = queryName;
//ImageServiceLayer doesn't have drawingInfo
if(!layerInfo.drawingInfo){
layerInfo.drawingInfo = {};
}
layerInfo.drawingInfo.renderer = renderer.toJson();
layerInfo.drawingInfo.transparency = 0;
layerInfo.minScale = 0;
layerInfo.maxScale = 0;
layerInfo.effectiveMinScale = 0;
layerInfo.effectiveMaxScale = 0;
layerInfo.defaultVisibility = true;
//only keep necessary fields
var necessaryFieldNames = this._getOutputFields();
layerInfo.fields = array.filter(layerInfo.fields, lang.hitch(this, function(fieldInfo){
return necessaryFieldNames.indexOf(fieldInfo.name) >= 0;
}));
var featureCollection = {
layerDefinition: layerInfo,
featureSet: null
};
resultLayer = new FeatureLayer(featureCollection);
} else {
//use graphics layer
this._resetAndAddTempResultLayer();
resultLayer = this.tempResultLayer;
}
this.currentAttrs.query.resultLayer = resultLayer;
this.queryResults.resultLayer = resultLayer;
//set renderer
resultLayer.setRenderer(renderer);
return resultLayer;
},