JQVMap - How to show onregionclick data values

var setMap = function (name) {
        var data = {
            map: 'world_en',
            backgroundColor: null,
            borderColor: '#333333',
            borderOpacity: 0.5,
            borderWidth: 1,
            color: '#c6c6c6',
            enableZoom: true,
            hoverColor: '#c9dfaf',
            hoverOpacity: null,
            values: sample_data,
            normalizeFunction: 'linear',
            scaleColors: ['#b6da93', '#909cae'],
            selectedColor: '#c9dfaf',
            selectedRegion: null,
            showTooltip: true,
            onLabelShow: function (event, label, code) {

            },
            onRegionOver: function (event, code) {
                if (code == 'ca') {
                    event.preventDefault();
                }
            },
            onRegionClick: function (element, code, region) {
                var message = 'You clicked "' + region + '" which has the code: ' + code.toUpperCase();
                alert(message);
            }
        };

        data.map = name + '_en';
        var map = jQuery('#vmap_' + name);
        map.width(map.parent().parent().width());
        map.show();
        map.vectorMap(data);
        map.hide();
    }

Does anyone know how to use click area values ​​in the onRegionClick function? I use this map to provide site statistics and I want to warn that we click something like "1000 views in the USA (USA)"

+5
source share
1 answer

As I said in my comment, I found out about the solution right after I asked the question, but for those who have this small problem, I just submit my solution. You just need to add the line you want to display on the shortcut.

onLabelShow: function (event, label, code) {
    if(sample_data[code] > 0)
        label.append(': '+sample_data[code]+' Views'); 
}

hope this helps.

+7
source

All Articles