Re: More information about HeatMapLayer/HeatMapLayerOptions

633 views
Skip to first unread message

Enoch Lau (Google Employee)

unread,
Jul 7, 2012, 6:16:43 AM7/7/12
to google-map...@googlegroups.com
The first color in the array represents an intensity of 0 and the last color in the array represents the maximum intensity (either automatically determined, or manually set through the maxIntensity option). Colors in between are taken to be evenly spaced. For example, if you have this gradient:
  ['red', 'green', 'blue']
and the maximum intensity is 10, 'red' means an intensity of 0, 'green' means 5, and 'blue' means 10. If the intensity is 7.5, then it's halfway between green and blue. Typically, you would want the first entry in the gradient to be 'transparent' or some semi-transparent color, otherwise your entire map will be covered up.

Enoch

On Saturday, July 7, 2012 3:11:35 AM UTC+10, Hunter McMillen wrote:
Hello,

I am working on a project where our team has previously been drawing our own heat maps, but we stumbled upon the HeatMapLayer in the API the other day and now it is my task to try and integrate it into our application. I was wondering if there is any more information about the HeatMapLayerOptions and the HeatMapLayer itself. I am particularly interested in the gradient option of the HeatMapLayerOptions; this is the description that is posted in the api:

   gradient Array<string> The color gradient of the heatmap, specified as an array of CSS color strings. All CSS3 colors are supported except for extended named colors

I was hoping for more explanation as to how to build this array for the gradient, i.e. how will the color at position X of the array be interpreted by the HeatMapLayer? I have currently just been trying a bunch of colors in the array to disastrously colorful  results.

Any help would be appreciated.

Thanks,
Hunter McMillen


Hunter McMillen

unread,
Jul 9, 2012, 8:12:26 AM7/9/12
to google-map...@googlegroups.com
Thank you very much, this is exactly what I was looking for.

Hunter McMillen

Hunter McMillen

unread,
Jul 10, 2012, 10:21:03 AM7/10/12
to google-map...@googlegroups.com
I was hoping that you could help me with something else also. When I initially added the HeatmapLayer to our application is was hardcoded but it also worked fine. Now that I have moved it to a proper position in our application I receive this error on the last element of every data array I try to pass in:

'Invalid value at position 334: [object Object]'

But upon further inspection the element at position 334 is a WeightedLocation object just like all the others.

Any thoughts as to why this could be happening?


On Saturday, July 7, 2012 6:16:43 AM UTC-4, Enoch Lau (Google Employee) wrote:

Rossko

unread,
Jul 10, 2012, 12:53:19 PM7/10/12
to Google Maps JavaScript API v3
> Any thoughts as to why this could be happening?

Wild guesses:
You have a superflous comma at the end?
Your code attempts to read beyoend the last element?

Hunter McMillen

unread,
Jul 10, 2012, 1:07:32 PM7/10/12
to google-map...@googlegroups.com
I use a for in loop to iterate over the array so I don't believe that I could be reading past element 334, The extra comma would throw an error in firebug. 

327: {"location":{"$a":-35.5,"ab":172},"weight":"11"} object music.js:730
328: {"location":{"$a":-36.5,"ab":151},"weight":"1"} object music.js:730
329: {"location":{"$a":-37.5,"ab":151},"weight":"1"} object music.js:730
330: {"location":{"$a":-37.5,"ab":168},"weight":"3"} object music.js:730
331: {"location":{"$a":-37.5,"ab":169},"weight":"6"} object music.js:730
332: {"location":{"$a":-39.5,"ab":161},"weight":"4"} object music.js:730
333: {"location":{"$a":-39.5,"ab":162},"weight":"5"} object music.js:730
334: {"location":{"$a":-39.5,"ab":165},"weight":"6"} object music.js:730

This is what my data looks like, the error is thrown on element 334, but when I remove that element; the error just gets propagated to element 333.

Hunter

Michael Geary

unread,
Jul 10, 2012, 1:49:19 PM7/10/12
to google-map...@googlegroups.com
Clearly, you have an off-by-one error. Or maybe you need a closure. Or something else is wrong.

Not much help, is it? :-)

Give us a link to a test page and you may get some more useful replies...

-Mike

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/Xw_1pUWNFpQJ.

To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Hunter McMillen

unread,
Jul 10, 2012, 3:10:12 PM7/10/12
to google-map...@googlegroups.com
Sorry for the extremely vague description of my problem, I figured out the cause however. The weight property in the WeightedLocation object was being set to a String value when it only accepts numeric values. Sorry for the time waste. 

Hunter
-Mike


To post to this group, send email to google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-api-v3+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages