|
4 | 4 | * @version 1.5.1 |
5 | 5 | * @link http://jqvmap.com |
6 | 6 | * @license https://github.com/manifestinteractive/jqvmap/blob/master/LICENSE |
7 | | - * @builddate 2016/05/18 |
| 7 | + * @builddate 2016/06/02 |
8 | 8 | */ |
9 | 9 |
|
10 | 10 | var VectorCanvas = function (width, height, params) { |
@@ -848,16 +848,23 @@ JQVMap.prototype.positionPins = function(){ |
848 | 848 | pinObj = jQuery(pinObj); |
849 | 849 | var countryId = map.getCountryId(pinObj.attr('for').toLowerCase()); |
850 | 850 | var countryObj = jQuery('#' + countryId); |
851 | | - |
852 | | - var bbox = document.getElementById(countryId).getBBox(); |
853 | | - var position = countryObj.position(); |
| 851 | + var bbox = countryObj[0].getBBox(); |
854 | 852 |
|
855 | 853 | var scale = map.scale; |
| 854 | + var rootCoords = map.canvas.rootGroup.getBoundingClientRect(); |
| 855 | + var mapCoords = map.container[0].getBoundingClientRect(); |
| 856 | + var coords = { |
| 857 | + left: rootCoords.left - mapCoords.left, |
| 858 | + top: rootCoords.top - mapCoords.top |
| 859 | + }; |
856 | 860 |
|
857 | | - var left = position.left + (bbox.width / 2) * scale - pinObj.width() / 2, |
858 | | - top = position.top + (bbox.height / 2) * scale - pinObj.height() / 2; |
| 861 | + var middleX = (bbox.x * scale) + ((bbox.width * scale) / 2); |
| 862 | + var middleY = (bbox.y * scale) + ((bbox.height * scale) / 2); |
859 | 863 |
|
860 | | - pinObj.css('left', left).css('top', top); |
| 864 | + pinObj.css({ |
| 865 | + left: coords.left + middleX - (pinObj.width() / 2), |
| 866 | + top: coords.top + middleY - (pinObj.height() / 2) |
| 867 | + }); |
861 | 868 | }); |
862 | 869 | }; |
863 | 870 |
|
|
0 commit comments