Search code examples
latitude-longitudejvectormapcoordinate-transformationmap-projections

How to find the BBOX coordinates of a jvectormap


I have the SVG file of a particular state, I have successfully converted the svg coordinates into a jvectormap, but I dont know how to identify the bbox coordinates of the projected region, can any one help me to identify it ?


Solution

  • Assuming your map has been instanced in my_map, get a map reference:

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

    You can get the bbox of a region in following way:

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

    You will get for example:

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

    Is this what you need?