Search code examples
javascriptjqvmap

Using custom codes on jqvmap


anyone knows if there is a way to use customized id in order to use setSelectedRegion? The documentation says that we have to use the ISO region code:

SelectedRegion: This is the Region that you are looking to have preselected (two letter ISO code, defaults to null )

because my svg is very customized, i mapping a region at level state, wich haven't iso codes (i think)

I supposse that the first key on json object like "9J", "VE" or "GO" are the code regions... and supposse that code is used on selectedRegion method...

This is my svg js file (truncated obviusly)

jQuery.fn.vectorMap('addMap', 'safe', {"width":300,"height":210,"pathes":{
"9J":{"path":".........","name":"first region"},
"VE":{"path":".........","name":"second region"},
"GO":{"path":".........","name":"third region"}
}});

now, the init code is this:

$('#vmap').vectorMap({
                map: 'safe',
                backgroundColor: '#E0E9A7',
                color: '#011631',
                hoverOpacity: 0.6,
                selectedRegion: 'VE',
                selectedColor: '#c9dfaf',
                borderColor: 'white',
                enableZoom: false,
                showTooltip: true,
                scaleColors: ['#C8EEFF', '#006491'],
                normalizeFunction: 'polynomial',
                onRegionClick: function(element, code, region)
                    {
                        if(location.href.indexOf('com_localidades')==-1){
                            location.href='index.php?option=com_location&loc='+region;
                        }else{
                            $('#vmap').vectorMap('set', 'selected', true, 'VE');
                        }
                    }
            });

thanks in advance!

  1. List item

Solution

  • It is an error in the documentation.

    It should be selectedRegions['VE']

    (https://github.com/manifestinteractive/jqvmap/issues/75)