I am using JQVMAP to generate some maps of the US. The plugin has an onRegionClick callback. I am trying to zoom in to the clicked state within this function. I kind of have an idea of how to do it by converting the SVG path returned to me onClick to viewBox coordinates, however, I am having trouble with the conversion. Here is what I have so far.
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#vmap').vectorMap(
{
map: 'usa_en',
backgroundColor: '#a5bfdd',
borderColor: '#818181',
borderOpacity: .50,
borderWidth: 1,
color: '#f4f3f0',
enableZoom: false,
hoverColor: '#c9dfaf',
hoverOpacity: null,
normalizeFunction: 'linear',
scaleColors: ['#b6d6ff', '#005ace'],
selectedColor: '#c9dfaf',
selectedRegion: null,
showTooltip: true,
onRegionClick: function(element, code, region)
{
//$('#vmap > svg')[0].setAttribute('viewBox', vmlPath);
console.log(region.path);
console.log(region.name);
}
});
});
</script>
Link to live demo. How can I convert the SVG path to viewBox coordinates? Am i going about this the right way? Or is there a better way to do this? My ultimate goal is to zoom into the state onRegionClick.