Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jVectorMap mark selected state

i found the plugin jVectorMap and i'm trying to mark the state that i selected with a diferente color

the same way that hover happens, but i what i want is, when clicked, the state keep "active" with some color.

the plugin have some actions like onRegionClick:

$('#map-teste').vectorMap({
    map: 'br_en',
    onRegionClick: function(event, code){
        alert(code); // return the state
    }
});

but i dont have any idea how to do this.

anyone achieve this ?

like image 302
Ricardo Binns Avatar asked May 27 '26 05:05

Ricardo Binns


1 Answers

You can set the color for selected regions by adding regionStyle config parameters to the instantiation of your map. You would also want to set the regionSelectable to true:

$('#map-teste').vectorMap({
    map: 'br_en',
    onRegionClick: function(event, code){
        alert(code); // return the state
    },
    regionsSelectable: true,
    regionStyle: {
        selected: {
            fill: 'orange'
        }
    }
});
like image 71
Mads Hansen Avatar answered May 31 '26 17:05

Mads Hansen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!