create line graphic in WAB

6271
58
Jump to solution
08-26-2015 08:54 AM
TerryGustafson
Occasional Contributor II

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

0 Kudos
58 Replies
RobertScheitlin__GISP
MVP Emeritus

Terry,

  Here is your jack rabbit finish. Study carefully.

TerryGustafson
Occasional Contributor II

The jack rabbit comment cracked me up.  First laugh I have had in a couple weeks.  thanks for the help..  I did have a few questions. 
1. When you set the var gra = new graphic, I understand the rs object but what are the null's?

2.What does the this.shelter.hide do?

3. What does the extend.expand(1.4) do?

4. What does the catch (e) catch?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Terry,

   Glad to give a laugh.

  1. If you look at the Graphics constructor you will see that the first property in the constructor is the Geometry, as you don't need any for your graphic you submit null, next is your symbology, not needed either, the attributes, then infoTemplate
  2. This.shelter.hide() hides the progress indicator/loading shelter.
  3. Extend.expand expands the current graphics extent by 40%
  4. Try Catch, tries to run some code and if it errors the catch with catch the error e is the error variable.
0 Kudos
TerryGustafson
Occasional Contributor II

I need to learn to use the ArcGIS API for javascript as a better resource for understanding syntax and requirements.  My next step will be to try and incorporate a return error if the user enters an incorrect corridor name, or the route length is greater then the segment length.  When I generated the service I added the LOC_ERROR field which returns these errors.. Any pointers where to start with that?   Thanks again for your help.

0 Kudos
TerryGustafson
Occasional Contributor II

I:'m thinking that I will add an if statement that if the LOC_error field is "NO ERROR" then return segment.  else is LOC_ERROR is "Route Not Found" then return message""Please enter route with correct format."  then repeat this for cases of starting point is before the start of the route, ending point is past the end of the route.  Does that sound right?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Terry,

   Are you sure that you would want to limit it to only "NO ERROR"? What about "PARTIAL MATCH FOR THE TO-MEASURE"? Currently this draw the route anyway but ignores the incorrect to measure provided.

0 Kudos
TerryGustafson
Occasional Contributor II

sorry again clear as mud..  I just did not type the rest out.  I meant that "repeat this for cases of starting point is before the start of the route, ending point is past the end of the route." If the starting point was before the start of the route the error would be "Partial MATCH for the from-measure" and the response would be something like "please enter valid starting location",and like you said if the ending location is past the end length of the segment the error would be "PARTIAL MATCH FOR THE TO-MEASURE" with a return message of "please check length of route as entered ending location is past the length of route"

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

sounds good. An if statement should be able to handle this.

0 Kudos
TerryGustafson
Occasional Contributor II

When I get a chance to start working on this will my “if” statements be in the located in the following section of code?

renderResult: function (result) {
                console.info(result);
                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();
                if (allFeatures.length > 0) {
                    try {
                        var extent = graphicsUtils.graphicsExtent(allFeatures);
                        if (extent) {
                            this.map.setExtent(extent.expand(1.4));
                        }
                    } catch (e) {
                        console.error(e);
                    }
                }
            }
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

yep

0 Kudos