onRegionClick fires when dragging #19

Closed
Rct567 opened this Issue Jun 23, 2012 · 2 comments

Comments

Projects
None yet
2 participants
@Rct567

Rct567 commented Jun 23, 2012

onRegionClick fires and a region is selected when dragging, but when you try to drag the map it isn't really a 'click' on a region.

@Rct567

This comment has been minimized.

Show comment Hide comment
@Rct567

Rct567 Jun 24, 2012

If anyone else finds this a issue, here is a way to solve it:

$('#vmap').vectorMap({
    map: 'world_en',
    backgroundColor: null,
    color: '#619EDE',
    hoverOpacity: 0.7,
    selectedColor: '#619EDE',
    enableZoom: true,
    showTooltip: true,
    scaleColors: ['#C8EEFF', '#006491'],
    normalizeFunction: 'polynomial',
    onRegionClick: function(element, code, region) {
        if (jQuery('#vmap').data('mapObject').isMoving == false) {
            // * real click *
        }
    }
});

var map = jQuery('#vmap').data('mapObject');
map.isMoving = false;
map.isMovingTimeout = false;
var mouseDown = false;

map.container.mousemove(function (e){

    if (mouseDown) {
        map.isMoving = true;
        if (map.isMovingTimeout != false) {
            clearTimeout(map.isMovingTimeout);
        }
    }

    return false;

}).mousedown(function (e){
    mouseDown = true;
    return false;
}).mouseup(function (){
    mouseDown = false;
    map.isMovingTimeout = setTimeout(function(){
        map.isMoving = false;
    }, 100);
    return false;
});

Rct567 commented Jun 24, 2012

If anyone else finds this a issue, here is a way to solve it:

$('#vmap').vectorMap({
    map: 'world_en',
    backgroundColor: null,
    color: '#619EDE',
    hoverOpacity: 0.7,
    selectedColor: '#619EDE',
    enableZoom: true,
    showTooltip: true,
    scaleColors: ['#C8EEFF', '#006491'],
    normalizeFunction: 'polynomial',
    onRegionClick: function(element, code, region) {
        if (jQuery('#vmap').data('mapObject').isMoving == false) {
            // * real click *
        }
    }
});

var map = jQuery('#vmap').data('mapObject');
map.isMoving = false;
map.isMovingTimeout = false;
var mouseDown = false;

map.container.mousemove(function (e){

    if (mouseDown) {
        map.isMoving = true;
        if (map.isMovingTimeout != false) {
            clearTimeout(map.isMovingTimeout);
        }
    }

    return false;

}).mousedown(function (e){
    mouseDown = true;
    return false;
}).mouseup(function (){
    mouseDown = false;
    map.isMovingTimeout = setTimeout(function(){
        map.isMoving = false;
    }, 100);
    return false;
});
@manifestinteractive

This comment has been minimized.

Show comment Hide comment
@manifestinteractive

manifestinteractive Jul 3, 2012

Collaborator

@rickonline Anyway you can make these changes and do a pull request? I can test them and merge them in if you can, it would be super awesome ;)

Collaborator

manifestinteractive commented Jul 3, 2012

@rickonline Anyway you can make these changes and do a pull request? I can test them and merge them in if you can, it would be super awesome ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment