Skip to content
gka edited this page Jun 4, 2012 · 6 revisions

Kartograph tooltips are based on the wonderful qTip plugin for jQuery, so you need to include at least the qTip JS and CSS files.

<script src="js/jquery.qtip.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery.qtip.min.css">

Then you have two ways to add your custom tooltips to a map layer, by either passing a dictionary of path-ids or a function that returns the tooltip contents.

Using a dictionary

map.addLayer({ id: 'countries', key: 'iso3' });

tt = {
   DEU: 'Here is a <em>tooltip</em> for Germany (no title)',
   FRA: ['Title for France', 'Here is a <em>tooltip body</em> for France']
};

map.tooltips({
   layer: 'countries',
   tooltips: tt
});

Using a function

map.addLayer({ id: 'countries', key: 'iso3' });

map.tooltips({
   layer: 'countries',
   tooltips: function(path_id, path) {
     return 'some tooltip content'; // or ['tooltip title', 'tooltip body']
   }
});
Clone this wiki locally