I am interpreting GPS location data in google map, here i would like create a path with gradient which starts with red and ends with orange
this tutorial has only a straight single color line as path
following code is responsible for path in gmap
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
How can i change this to Gradient ?
with help of @JerryDuwall 's answer i have done this
Of-course it is not a gradient but some how attractive than single color line
And
makeGradientColor
declartion followsYou could use the
interpolate
method within the Geometry library (https://developers.google.com/maps/documentation/javascript/reference#spherical) to getx
positions along the straight-line path (I'm assuming you're dealing with straight lines). This would allow you to constructx-1
polylines. You could then generate colors within a red-orange gradient (refer to Generate colors between red and green for an input range) and assign them to the strokeColor of each of yourx-1
polylines.Increase
x
to get a more subtle gradient.