bjornd / jvectormap

jvectormap.com
GNU Affero General Public License v3.0
1.39k stars 431 forks source link

Using getRegionName with drill down jvectormap #412

Open the7oka opened 7 years ago

the7oka commented 7 years ago

It's very simple actually and i'm sure the answer is far more simple but the documentation for Jvectormap is really bad. I need to getRegionName() for a county on a drill down map of the states but it's not working for some reason. Here's my code:

<script>

$(function(){

new jvm.MultiMap({
  container: $('#map'),
  maxLevel: 1,
  main: {
    map: 'us_lcc',
    onRegionClick:function(e,code){
    console.log(getRegionName(code))
  }
},
mapUrlByCode: function(code, multiMap){
  return '/assets/jquery-jvectormap-data-'+
         code.toLowerCase()+'-lcc-en.js';
}
});

});
</script>

Please note that i had to adjust the jquery-jvectormap-2.0.3.min.js file for the state map to inherit from the main map

ghost commented 5 years ago

Can I ask, how did you adjust the min.js file to help inheritance? My drill-down won't fetch a new map when I click, and I'm hoping your solution might apply as a general fix.

newspecies commented 4 years ago

Because on drilldown, map object create under the new div tag, you need to identify the map object under that new div...

Use this brow...