neveldo / jQuery-Mapael

jQuery plugin based on raphael.js that allows you to display dynamic vector maps
https://www.vincentbroute.fr/mapael/
MIT License
1.01k stars 195 forks source link

get elem idfrom tooltip function #394

Open estratagema opened 6 years ago

estratagema commented 6 years ago

Hi, I am trying to retreive the elem id hover it from any parameter of content function in tooltip inside defaultArea. Like as defaultArea: { tooltip: {
"content": function (info) { return (info.elem.id) } } } Is it possible? Thanks in advance.

Adolfo

neveldo commented 6 years ago

Hi @estratagema ,

Sorry for my late answer ! Of course you can retrieve the ID of the area within the tooltip, here is a code sample :

{
    "map": {
        "name": "world_countries",
        "zoom": {
            "enabled": true,
            "maxLevel": 10
        },
        "defaultArea": {
            "tooltip": {
                "content": function (elem) {
                    console.log(elem[0].getAttribute('data-id')); 
                    return "ok";
                }
            }
        }
    }
}

I hope it will help you !