I have a polyline and I want to colourise each line between two points depending on its length. What are my options? I found no way to do that on a single object and the lines I have to work with have up to 15,000 points, so generating fifteen thousand single lines of different colours isn’t particularly efficient.
Share
The Polyline Options state that there’s one
strokeColorfor a polyline. You’d have to do it yourself, manually. You could probably automate the process, slightly, by building a function that takes an array of points, calculates the distance between the first 2, decides the color, creates a polyline, then moves on to the next point. Rinse and repeat. Yeah, 15K points is going to be slow, although I suspect that even calling GMaps API with a 15K array of LatLng isn’t that fast either…