Color polyline segments in different colors

680
1
08-29-2022 01:23 AM
ofirrosner
New Contributor III

Hello
I'm creating polylines on my layer via the sketch editor or via PolylineBuilder  class
each line contains many points (and of course a line between them).

My question is, if i can color each segment, i.e, each line between 2 points in different color?

my current workaround is to create, instead of 1 "big" polyline, X "small" polyline, as much as my "big" polyline line amount, and color each small polyline in different color.

My main issues its very instance of the system performance vise, because i don't only have 1 "big" but a lot of them 

0 Kudos
1 Reply
ThadTilton
Esri Contributor

This is an interesting question, but I think the basic answer is "no". The lowest level at which symbols are applied is for a geoelement (feature or graphic, ie), so it sounds like your approach of showing a larger geometry using geoelements for each segment is the best workaround. If you only want to display feature segments individually but not store them that way, you might consider a "hybrid" approach where you store only the larger feature in your dataset, but use a graphics overlay to display the segments with unique symbols. Especially if you only need to display segments for certain workflows. Perhaps allow the user to select a polyline that they want to see the segments for (?).

Performance might be a concern if you start handling lots of segments (thousands). The guide doc topic here has some tips for improving performance when working with a graphics-intensive app: https://developers.arcgis.com/net/programming-patterns/performance-considerations/#graphics

One tip is to use a renderer for a graphics overlay rather than symbols for each graphic. To implement that, you might do something like generate a random number for each graphic (perhaps between 1-10, eg) and apply a renderer to the overlay that shows a unique color for each possible value (1-10, or whatever range you use).

0 Kudos