I'm wondering if anyone has generated a simpleLine Symbol in WAB. I'm wanting to pass a start and end location offset and return a line symbol from the entered values. does anyone know of an example out there to look at?
TIA
Solved! Go to Solution.
Terry,
So it comes down to basic programming syntax issues. You don't seem to be paying attention to your use of a comma vs. a semicolon. All the errors are in the executeGP function. I will point them out and try to explain what the issue is.
executeGP: function (rs) { this.shelter.show(); this.map.graphics.clear(); var lineSymbol = new SimpleLineSymbol( SimpleLineSymbol.setColor(new Color([255, 255, 0, 0.5]); SimpleLineSymbol.setWidth(2))); ^Problem 1 ^Problem 2 graphic = new Graphic(rs.mapSegment, lineSymbol), features = [graphic], featureSet = new FeatureSet(), ^Problem 3 featureSet.features = features, ^Problem 4 var params = { "Route_Points": featureSet, "Route_Points_Events1 ": { "esriGeometryPolyline": true, "HasZ": "false", "HasM": "true" }, "Keep_only_the_closest_route_location": false }; this.gp.submitJob(params, lang.hitch(this, this.processGP)); },
Each problem number is detailed below:
Note 1:
Here is how I would replace your lines 4 and 5 by just supplying all the SimpleLineSymbol properties in the constructor:
var lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 255, 0, 0.5]), 2),
Ok that mas sense as well.. So I created this function to execute when the "returnseg" button is click. I set a break point at line 2 but when I run the widget it does not seem to get there. I was expecting to see the value from the CorridorTextBox. Is my syntax for that .get('value'), correct? Do you use the debugging console through brackets or just run the application?
_onreturnsegClicked: function () { var Corridor = this.CorridorTextBox.get('value'), FromOffset = this.fromOffsetTextBox.get('value'), ToOffset = this.toOffsetTextBox.get('value'), RouteSeg = new RouteSeg(Corridor, FromOffset, ToOffset), rs = { mapSegment: RouteSeg }; this.executeGP(rs); },
The other question I forgot to ask was by are my buttons different? I don’t see anything in the html that defines the color or style of the button.
Terry,
I have a couple other widgets like this and was hoping I could limp my way to creating this one and learn from it. When I try and call the _bindEvents function I get the following.
TypeError: Unable to set property 'src' of undefined or null reference TypeError: Unable to set property 'src' of undefined or null reference
at postCreate (http://mdthlnisdp264.mdthq.mt.ads:3344/webappbuilder/apps/2/jimu.js/dijit/LoadingShelter.js:42:7)
at n (http://js.arcgis.com/3.13/init.js:106:75)
at postCreate (http://mdthlnisdp264.mdthq.mt.ads:3344/webappbuilder/apps/2/widgets/CreateRouteSegment/Widget.js:53:14)
at create (http://js.arcgis.com/3.13/init.js:1123:343)
at postscript (http://js.arcgis.com/3.13/init.js:1122:94)
at Anonymous function (http://js.arcgis.com/3.13/init.js:108:190)
at createWidget (http://mdthlnisdp264.mdthq.mt.ads:3344/webappbuilder/apps/2/jimu.js/WidgetManager.js:285:11)
at Anonymous function (http://mdthlnisdp264.mdthq.mt.ads:3344/webappbuilder/apps/2/jimu.js/WidgetManager.js:105:21)
at Anonymous function (http://js.arcgis.com/3.13/init.js:177:287)
at k (http://js.arcgis.com/3.13/init.js:199:425)
{
: ,
__proto__: {
: ,
__proto__: { },
message: "",
name: "TypeError"
},
description: "Unable to set property 'src' of undefined or null reference",
message: "Unable to set property 'src' of undefined or null reference",
name: "TypeError",
number: -2146823281,
stack: "TypeError: Unable to set property 'src' of undefined or null reference
at postCreate (http://mdthlnisdp264.mdthq.mt.ads:3344/webappbuilder/apps/2/jimu.js/dijit/LoadingShelter.js:42:7)
at n (http://js.arcgis.com/3.13/init.js:106:75)
at postCreate (http://mdthlnisdp264.mdthq.mt.ads:3344/webappbuilder/apps/2/widgets/CreateRouteSegment/Widget.js:53:14)
at create (http://js.arcgis.com/3.13/init.js:1123:343)
at postscript (http://js.arcgis.com/3.13/init.js:1122:94)
at Anonymous function (http://js.arcgis.com/3.13/init.js:108:190)
at createWidget (http://mdthlnisdp264.mdthq.mt.ads:3344/webappbuilder/apps/2/jimu.js/WidgetManager.js:285:11)
at Anonymous function (http://mdthlnisdp264.mdthq.mt.ads:3344/webappbuilder/apps/2/jimu.js/WidgetManager.js:105:21)
at Anonymous function (http://js.arcgis.com/3.13/init.js:177:287)
at k (http://js.arcgis.com/3.13/init.js:199:425)"
}
"TypeError: Unable to set property 'src' of undefined or null reference
at postCreate (http://mdthlnisdp264.mdthq.mt.ads:3344/webappbuilder/apps/2/jimu.js/dijit/LoadingShelter.js:42:7)
at n (http://js.arcgis.com/3.13/init.js:106:75)
at postCreate (http://mdthlnisdp264.mdthq.mt.ads:3344/webappbuilder/apps/2/widgets/CreateRouteSegment/Widget.js:53:14)
at create (http://js.arcgis.com/3.13/init.js:1123:343)
at postscript (http://js.arcgis.com/3.13/init.js:1122:94)
at Anonymous function (http://js.arcgis.com/3.13/init.js:108:190)
at createWidget (http://mdthlnisdp264.mdthq.mt.ads:3344/webappbuilder/apps/2/jimu.js/WidgetManager.js:285:11)
at Anonymous function (http://mdthlnisdp264.mdthq.mt.ads:3344/webappbuilder/apps/2/jimu.js/WidgetManager.js:105:21)
at Anonymous function (http://js.arcgis.com/3.13/init.js:177:287)
at k (http://js.arcgis.com/3.13/init.js:199:425)"
Terry,
startup: function () {
this.inherited(arguments);
this._bindEvents();
},
I though the _bindEvent went i nthe postCreate: function like this?
function () { this.inherited(arguments); this.gp = new Geoprocessor("https://app.mdt.mt.gov/arcgis/rest/services/LRS/ReturnRouteSegment/GPServer/ReturnRouteSegment"); this._bindEvents();
Terry,
Adding it to postCreate is fine. You must issues with your ordering of requires and vars.
if you have:
define(['dojo/_base/declare',
'jimu/BaseWidget',
Then you MUST have
function (declare, BaseWidget
In that same exact order. You have a couple of things off in yours.
Oh ok. Thank you for clarifying that..
Its a snails pace but think I'm making progress.. I can get it o return and pass the data to the service but I see to get a url error..
function (rs) { var RP ={ "displayFieldName": "", "fields": [ "name": "OBJECTID", "type": "esriFieldTypeOID", "alias": "OBJECTID" "name": "Corridor", "type": "esriFieldTypeString", "alias": "Corridor", "length": 8 "name": "from_offset", "type": "esriFieldTypeSingle", "alias": "from_offset" "name": "to_offset", "type": "esriFieldTypeSingle", "alias": "to_offset" "features": [{ "attributes":{ "OBJECTID": 1, "Corridor": rs.Corridor, "from_offset": rs.FromOffset, "to_offset": rs.ToOffset "exceededTransferLimit": false var params = { "Route_Points": RP, this.gp.submitJob(params, lang.hitch(this, this.processGP)); function () { var Corridor = this.CorridorTextBox.value, this.fromOffsetTextBox.value, this.toOffsetTextBox.value, "Corridor":Corridor, "FromOffset":FromOffset, "ToOffset":ToOffset this.executeGP(rs);