create line graphic in WAB

3378
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
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Terry,

  Here is your jack rabbit finish. Study carefully.

View solution in original post

58 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Terry,

   Use some simple code like this:

var polyline = new Polyline(this.map.spatialReference);

polyline.addPath([new Point(10,10), new Point(20,20), new Point(30,30)]);

var lineGra = new Graphic(polyline, new SimpleLineSymbol());

0 Kudos
TerryGustafson
Occasional Contributor II

Robert, Sorry once again I was as clear as mud..  I could have put a little more detail into what I'm trying to accomplish.  I have a GP service that creates a route event layer.  It has a corridor name and  from and to offset fields.  The user will enter the coordinate and mile post offset and I want it to return a simpleLine graphic.  Here is what I have so far.  Robert, Sorry once again I was as clear as mud..  I could have put a little more detail into what I'm trying to accomplish.  I have a GP service that creates a route event layer.  It has a corridor name and  from and to offset fields.  The user will enter the coordinate and mile post offset and I want it to return a simpleLine graphic.  Here is what I have so far.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Terry,

   Wow there is nothing that is close to working in the widget code you provided. Based on the GP service you are calling only having one parameter that is an input, I have no idea how you are expecting to draw a line on the map based on values like 10.5 and 15.9.

0 Kudos
TerryGustafson
Occasional Contributor II

I know there is nothing close to working I was just showing the code I had...  I was wondering if I could use the from_offset and to_offset fields from that parameter to generate my line.  I was thinking of using the measured shape from the gp service to return the corridor name and then the linear offset..

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Terry,

   You are going to have to explain your workflow a lot better then. Normally I would look at someones code and be able to determine a basic or suggested workflow but there is nothing in your code or the params of your GP that give me a clue on how you expect to be able and draw a line on the map.

0 Kudos
TerryGustafson
Occasional Contributor II

I'm sorry, my original post was not very clear..  Obviously my second was even worse.  I guess I was hoping to see some sample code that took a "from offset" and "to offset" and created a route between those two points and plotted a graphic line of that on the map.  I looked at some of the live apps that are out there and there was not really anything like it..  I guess the closest thing was the directions widget.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Terry,

   So are the "from offset" and "to offset" suppose to be actual points on the map or values like in your html place holder (i.e. 10.5). If they are just suppose to be numbers like 10.5 this is where you really lose me because 10.5 is not an X and Y so where would you place this singular number on the map? Now if the "from offset" and "to offset" and the "corridor name" goes to the GP and the GP returns a feature that has some geometry than that is a different matter.

0 Kudos
TerryGustafson
Occasional Contributor II

Yes you are correct in the later.  The users will enter the corridor and an offset of 10.5 to 15.9 for example then the GP would be hit and the GP returns a feature that has some geometry like a graphic line feature.  I did not know if only having the from_offset and to_offset fields would work or if they needed to be a parameter in the GP service.  Thanks for being so patient with my ignorance.

0 Kudos
ModyBuchbinder
Regular Contributor II

Hi

I think the best way is to use geoprocessing service.

Just build a simple python program that does the operation. The parameters will be the from, to and offset. The tool will create line feature class.

Then you publish and use it in WAB, it will return you thecreated feature class and a new layer.

Have Fun

Mody

0 Kudos