Create a scale key for jvectormap region colors

2019-08-10 02:31发布

问题:

I'd like to create a key to my map that shows the values associated with the different colors, as at the bottom of the drawing:

I can make a series of boxes easily enough. Is there a method somewhere I can input a value to get the color back that the map would use for that value?

回答1:

First you need a map object. If you have created a map with jvm.WorldMap constructor you have it already, otherwise if you have created a map using jQuery wrapper you can do:

var map = $('#map').vectorMap('get', 'mapObject');

Then to convert the value to color do the following:

var color = map.series.regions[0].scale.getValue(someValue);


标签: jvectormap