Search code examples
javascriptjqueryjqvmap

How to show values inside countries in JQVmap


I'm making a strategy game like Risk (but simpler). I'm doing the representation with JQVmap and I want to show inside the country the units that country have inside. Just show a number. Any ideas? I tried with onLabelShow but it displays only when mouse the mouse hovers over the country and the info is not inside the country borders.

Thanks!


Solution

  • I solved this by making a function that appends divs to the div with ID vmap. The bad thing is that you have to get the coordinates of each state. The div must be positioned 'absolute'. For example:

    $("#vmap").append("<div class='info' style='top: " + coord[1] +"px; left: "+coord[0]+"px'>"+ "text you want to show" + "</div>");