0

In Google Maps Javascript API for heat maps the default gradient displays red color in areas of higher density and changes to red as intensity decreases. In my application I need to show areas of higher intensity in green and lower intensity in red. I tried printing the default gradient values heatmap.get('gradient') only to get 'undefined' value. How can I get the default value of Google Maps API heat map gadient.

5

For anyone who needs it, here's the default gradient:

["rgba(102, 255, 0, 0)",
"rgba(102, 255, 0, 1)",
"rgba(147, 255, 0, 1)",
"rgba(193, 255, 0, 1)",
"rgba(238, 255, 0, 1)",
"rgba(244, 227, 0, 1)",
"rgba(249, 198, 0, 1)",
"rgba(255, 170, 0, 1)",
"rgba(255, 113, 0, 1)",
"rgba(255, 57, 0, 1)",
"rgba(255, 0, 0, 1)"]
0

By the documentation it looks that when using the default gradient the value of heatmap.get('gradient') is null. I think you'll have to create a new gradient array (like in the example), and when creating the heatmap add

   gradient:  gradient_array,

to the google.maps.visualization.HeatmapLayer declaration.

  • 1
    My question was how to find the default gradient. Any way I found the answer. just had to print console.log(heapmap) and then traverse throught the Object printed – Johnson Jul 12 '17 at 8:24
0

just print console.log(heapmap) and then traverse throught the Object printed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.