JVector onRegionClick Event Map

So, on the JVector map, I need a function, each area of ​​which is associated with a URL. Therefore, if you click on South Africa, you will be taken to a page with information about South Africa. I know I'm starting with onRegionClick: function (), but there’s a secret for me.

+4
source share
2 answers

Ok, as the documentation says:

onRegionClick

A callback function that will be called when the user clicks on the path area. The region code will be passed for the callback as an argument.

, , , . , , .

onRegionClick: function (event, code) {
    window.location.href = "yourpage?regionCode=" + code
},

, getRegionName , .

var regionName = map.getRegionName(code);
+6

html

<div class="map_jvector"></div>

javascript

        <script>                
            $('.map_jvector').vectorMap({
              map: 'africa',
              backgroundColor: '#ffffff',

              onRegionClick:function(event, code){            
                      var name = (code);                          
                            window.location.replace("http://your url address/"+code+"");
                      },

              series: {
                regions: [{
                  values: gdpData,
                 scale: ['#003471','#009eef', '#0076a3','#0d004c','#f26522','#9e0039'],
                  normalizeFunction: 'polynomial'
                }]
              },
              onRegionTipShow: function(e, el, code){
                el.html(el.html());
              }
            });

        </script>

" URL" , "+ code +" - JVector, , .

+1

All Articles