You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I modified JQVMap.prototype.positionPins with
var shift_x = map.canvas.rootGroup.getBBox().x;
var shift_y = map.canvas.rootGroup.getBBox().y;
to middleX, and middleY
JQVMap.prototype.positionPins = function(){
var map = this;
var pins = this.container.find('.jqvmap-pin');
var shift_x = map.canvas.rootGroup.getBBox().x;
var shift_y = map.canvas.rootGroup.getBBox().y;
jQuery.each(pins, function(index, pinObj){
pinObj = jQuery(pinObj);
var countryId = map.getCountryId(pinObj.attr('for').toLowerCase());
var countryObj = jQuery('#' + countryId);
var bbox = countryObj[0].getBBox();
var scale = map.scale;
var rootCoords = map.canvas.rootGroup.getBoundingClientRect();
var mapCoords = map.container[0].getBoundingClientRect();
var coords = {
left: rootCoords.left - mapCoords.left,
top: rootCoords.top - mapCoords.top
};
var middleX = (bbox.x * scale) + ((bbox.width * scale) / 2) - shift_x * scale;
var middleY = (bbox.y * scale) + ((bbox.height * scale) / 2) - shift_y * scale;
pinObj.css({
left: coords.left + middleX - (pinObj.width() / 2),
top: coords.top + middleY - (pinObj.height() / 2)
});
});
};
Lables shifted approximately to left 120px and bottom 55px
It can be reproduced with these settings.
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="jquery.vmap.js"></script>
<script type="text/javascript" src="jquery.vmap.ukraine.js" charset="utf-8"></script>
<script>
jQuery(document).ready(function () {
jQuery('#vmap').css({width:window.innerWidth, height:window.innerHeight}).vectorMap({
map: 'ukraine_ua',
hoverOpacity: 0.7,
hoverColor: false,
backgroundColor: '#fff',
borderColor: '#fff',
color:'#279fe0',
hoverColor: '#005bbb',
selectedColor: '#ffd500',
showLabels: true,
});
});
</script>
The text was updated successfully, but these errors were encountered: