47 lines
1.4 KiB
Plaintext
47 lines
1.4 KiB
Plaintext
JQVMap.prototype.placePins = function(pins, pinMode){
|
|
var map = this;
|
|
|
|
if(!pinMode || (pinMode !== 'content' && pinMode !== 'id')) {
|
|
pinMode = 'content';
|
|
}
|
|
|
|
if(pinMode === 'content') {//treat pin as content
|
|
jQuery.each(pins, function(index, pin){
|
|
if(jQuery('#' + map.getCountryId(index)).length === 0){
|
|
return;
|
|
}
|
|
|
|
var pinIndex = map.getPinId(index);
|
|
var $pin = jQuery('#' + pinIndex);
|
|
if($pin.length > 0){
|
|
$pin.remove();
|
|
}
|
|
map.container.append('<div id="' + pinIndex + '" for="' + index + '" class="jqvmap-pin" style="position:absolute">' + pin + '</div>');
|
|
});
|
|
} else { //treat pin as id of an html content
|
|
jQuery.each(pins, function(index, pin){
|
|
if(jQuery('#' + map.getCountryId(index)).length === 0){
|
|
return;
|
|
}
|
|
var pinIndex = map.getPinId(index);
|
|
var $pin = jQuery('#' + pinIndex);
|
|
if($pin.length > 0){
|
|
$pin.remove();
|
|
}
|
|
map.container.append('<div id="' + pinIndex + '" for="' + index + '" class="jqvmap-pin" style="position:absolute"></div>');
|
|
$pin.append(jQuery('#' + pin));
|
|
});
|
|
}
|
|
|
|
this.positionPins();
|
|
if(!this.pinHandlers){
|
|
this.pinHandlers = true;
|
|
var positionFix = function(){
|
|
map.positionPins();
|
|
};
|
|
this.container.bind('zoomIn', positionFix)
|
|
.bind('zoomOut', positionFix)
|
|
.bind('drag', positionFix);
|
|
}
|
|
};
|