Bing Maps 8 Color Gradient Legend

I’ve been investigating the Bing Maps V8 library. The documentation has many good but very short examples. The way I learn best is by taking existing examples and modifying them.


I created a demo that combines several features. The color gradient legend in the upper left corner of the map is created programmatically. Behind the scenes, legend information is stored so that each value between 0 (purple) and 100 (red) can be mapped to a color encoded as an RGB triple.

The legend is rendered as a custom pushpin. Whenever the user zooms the map or scrolls, the legend is redrawn so that it always appears in the upper left corner.

The demo has the shape of Colorado stored in WKT (“well known text”) format. When the user clicks on the “Color Colorado” button, the number value in the textbox (90 in the image) is fetched, converted to a color, and that color is used to shade Colorado.

Very interesting exercise.


This entry was posted in Miscellaneous. Bookmark the permalink.