Easy legend generation for the Google Charts API map chart type
April 4, 2008 | Posted by Jeffrey Barke | 3 comments
In an earlier post, I wrote "I agree with Bjørn that the lack of an API-generated legend is problematic, though one could be constructed via HTML adjacent to the chart." However, it turns out that creating a legend is a bit more difficult than I initially thought. The difficulty was brought to my attention via a post to the Google Charts API Google Group that requested help in writing a PHP function to determine the hex value of interpolated colors. Since I figured this would be a common problem, I wrote a PHP 4 class that will hopefully solve it. You can see the tmMapLegend class in action below with the map produced in the earlier tutorial. Learn more about the class and download it here: http://themechanism.com/barkode/code/tmmaplegend/.
- States carried by the Republicans in all four elections
- States carried by the Democrats in all four elections
- States carried by the Republicans in three of the four elections
- States carried by the Democrats in three of the four elections
- States carried by each party twice in the four elections
























[...] Easy legend generation for the Google Charts API map chart type: Your maps don’t have to exist without legends-this tutorial will show you how to make them. [...]
50 Cool Things You Can Do with Google Charts API | College@Home
June 5th, 1:57 pmUnfortunately this works for the States only
maps for hotels
October 30th, 7:15 pmHello, maps for hotels:
While it's true that the United States is the only country supported via the Google Charts API, there are country maps for Africa, Asia, Europe, the Middle East, South America and the world.
And the legend generator works for all map types!
Jeffrey Barke (theMechanism)
November 1st, 11:27 pm