如何找到 jvectormap 的 BBOX 坐标

How to find the BBOX coordinates of a jvectormap

我有一个特定状态的SVG文件,我已经成功地将svg坐标转换成jvectormap,但我不知道如何识别投影区域的bbox坐标,谁能帮我识别一下?

假设您的地图已在 my_map 中实例化,获取地图参考:

var mapObj = $('#my_map').vectorMap('get', 'mapObject');

您可以通过以下方式获取区域的bbox:

onRegionOver: function(evt, code){
  var bb = mapObj.regions[code].element.shape.getBBox();
  console.log(bb);
}

你会得到例如:

SVGRect
height:88.74008178710938
width:99.780029296875
x:705.31005859375
y:312.38995361328125

这是你需要的吗?