MKOverlayPathRenderer color dependent by property

101 views Asked by At

I would like to draw a line on my mapview with a gradient, but the gradient color on a specific position should be dependent on a property from the line (e.g speed or altitude)

I found several MKOverlayPathRenderer which can draw a gradient, but the color moves from the first in the array to the last, but in my case the color can repeat. They should not go from green to orange to red from start to end. Either they can be green to orange to green to orange to red to orange and so on...

My current implementation is to go through the location points and check the property, which is color dependent and then draw different polylines depending on the property. So the result is a big number of polylines, which is not good I think in terms of performance and it looks not smooth either.

Is this the correct way or is there one to draw one line and create a MKOverlayPathRenderer which can handle these colouring requirements?

thank you for any tips

0

There are 0 answers