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.
Do you think I should draw the feature if they enter an invalid from or to point?
renderResult: function (result) { console.info(result); var locError = result.value.features[0].attributes.LOC_ERROR if (locError === "No ERROR") { draw it } else if (locError === "ROUTE NOT FOUND") { return message "Invlaid Corridor name please re-enter" } else if (locError === "PARTIAL MATCH FOR THE FROM-MEASURE") { return message "Invlaid Beggining Accum. Mileage please re-enter" } else if (locError === "PARTIAL MATCH FOR THE TO-MEASURE") { return message "Invlaid Ending Accum. Mileage please re-enter" } var allFeatures = []; var lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 255, 0, 0.9]), 8); if (result.dataType === "GPFeatureRecordSetLayer") { var features = result.value && result.value.features; if (features && features.length > 0) { array.forEach(features, lang.hitch(this, function (feat) { allFeatures = allFeatures.concat(feat); feat.setSymbol(lineSymbol); this.map.graphics.add(feat); })); } } // this.shelter.hide();
Terry,
That is really up to you. I personally would, but report back the correct value. Like if I enter
Corridor: C000001E
Begin: 0
End: 1800
Return:
Loc_Error: "PARTIAL MATCH FOR THE TO-MEASURE"
Shape_Length: 1609430.9492044426
So I would provide a message like: "Corridor: C000001E length is only 1609430.9492044426".
You can use the message dijit just require: 'jimu/dijit/Message'
and call it like this:
new Message({ titleLabel: "Title", message: "Some message" });
Will the new Message return a popup displaying the title and message?
yes
Good Morning Robert,
How do I return to the function when one of my “else” statements fails? After thinking about it I don’t want to draw an incorrect segment.
else if (locError === "ROUTE NOT FOUND") {
return new Message({
titleLabel: "Data Entry Error",
message: "Invalid Corridor name please re-enter"
});
I think it would go here after the ok is clicked from the return newMessage
}
Terry,
Here is some example code for doing something based on a message dialog button(s) being clicked:
var qMessage = new Message({ type: 'question', titleLabel: this.nls.spatialchoicetitle, message: this.nls.spatialchoicemsg, buttons: [{ label: this.nls.buffergraphics, onClick: lang.hitch(this, lang.hitch(this, function () { qMessage.close(); var g = this.graphicsLayerBuffer.graphics[0]; intersectGeom = g.geometry; this.search(intersectGeom, this.spatialLayerIndex, null, null, dataSpatialType); })) }, { label: this.nls.selectiongraphics, onClick: lang.hitch(this, lang.hitch(this, function () { qMessage.close(); intersectGeom = this.unionGeoms(this.currentLayerAdded.graphics); this.search(intersectGeom, this.spatialLayerIndex, null, null, dataSpatialType); })) }] });
Ok, I got to work for the validation of my return route segment widget. I wanted to add the following validation to my get location from coordinate widget. But the onClick does not seem to close the function. Any ideas?
_onlatlongClicked: function () {
GLOBE.wkid = 4326;
if (this.LatTextBox.value) {
if ((!isNaN(this.LatTextBox.value) && !isNaN(this.LongTextBox.value))) {
var Lat = this.LatTextBox.value,
Long = this.LongTextBox.value,
LocPoint = new Point(Long, Lat),
mp = {
mapPoint: LocPoint
};
} else {
var qMessage = new Message({
type: 'Error',
titleLabel: "Invalid Corrdinate",
message: "Please re-enter valid valid coordinate",
button: [{
label: "Data Entry Error",
onClick: lang.hitch(this, lang.hitch(this, function () {
qMessage.close();
}))
}]
});
}
Robert,
Ok, I have my validation to ensure the coordinates that are entered are numbers. I was also going to validate that the created point was located in Montana. Do you know of a function for something like this?
I found this and thought it might work. What are your thoughts?
if( bb.ix <= p.x && p.x <= bb.ax && bb.iy <= p.y && p.y <= bb.ay ) {
// Point is in bounding box
}
Else {
//return error message “out of Montana”
}
bb is the bounding box, (ix,iy) are its top-left coordinates, and (ax,ay) its bottom-right coordinates. p is the point and (x,y) its coordinates.
Terry,
You need to get more familiar with the JS API. The extent and polygon objects have a contains function that you should use for this.