Where does the feature actions code go in the select widget manifest? What's wrong with this? Can someone please show me a correct sample? Thanks, cob
{
"name": "Select2",
"platform": "HTML",
"version": "2.6",
"wabVersion": "2.6",
"author": "Esri R&D Center Beijing",
"description": "",
"copyright": "",
"license": "http://www.apache.org/licenses/LICENSE-2.0",
"properties": {
"supportMultiInstance": false,
"featureActions": [{
"name": "ShowVertex",
"uri": "ShowVertexFeatureAction"
}]
}
}
Solved! Go to Solution.
Charles,
Your onExecute is not a function in your code the way you have your code setup... all those requires you have there need to be combined with the initial require array list and your onExecute need to be an actual function.
Cob,
This is what I would expect the code to look like:
define([
'dojo/_base/declare',
'jimu/BaseFeatureAction',
'jimu/WidgetManager',
"dojo/dom",
"dojo/_base/lang",
"dojo/json",
"esri/tasks/GeometryService",
"esri/tasks/AreasAndLengthsParameters"
], function(declare, BaseFeatureAction, WidgetManager, dom, lang, json, GeometryService, AreasAndLengthsParameters) {
var clazz = declare(BaseFeatureAction, {
iconFormat: 'png',
isFeatureSupported: function(featureSet) {
return featureSet.features.length > 0 && featureSet.features[0].geometry.type !== 'point';
},
onExecute: function(featureSet){
var geometry = featureSet.features[0].geometry;
var geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
geometryService.on("areas-and-lengths-complete", lang.hitch(this, function(evtObj){
var result = evtObj.result;
console.log(json.stringify(result));
dom.byId("area").innerHTML = result.areas[0].toFixed(3) + " acres";
dom.byId("length").innerHTML = result.lengths[0].toFixed(3) + " feet";
}));
//setup the parameters for the areas and lengths operation
var areasAndLengthParams = new AreasAndLengthsParameters();
areasAndLengthParams.lengthUnit = GeometryService.UNIT_FOOT;
areasAndLengthParams.areaUnit = GeometryService.UNIT_ACRES;
geometryService.simplify([geometry], lang.hitch(this, function(simplifiedGeometries) {
areasAndLengthParams.polygons = simplifiedGeometries;
geometryService.areasAndLengths(areasAndLengthParams);
}));
}
});
return clazz;
});
I am not convinced that you will get access to your area and length dom objects the way you are doing it though.
Just changed computers and had to start over(again) – it doesn’t seem to like the simplify method in line 33…but when I comment out that part of the line is says unexpected token in line 36 (with the })):)). If I do anything to that line the whole thing blows up and won’t show my feature action in the ellipse dropdown (which has happened like a thousand times).
I had a ? about the DOM but need to get the code working first. Thanks Robert - cob
Charles,
OK, then change this line:
var geometry = featureSet.features[0]
.geometry;
cob,
try replacing the GeomertyService url with your own GeometryService url then.
You mean, like the one on our arcgis server?
Ok that sort of works, but has to be on the network and most of our users are just in AGOL via internet. Is there any way to do it using the esri public service?