Maps made easy

Map examples

All map examples were generated with our plugin. Most examples can be imported directly to your plugin. A download button can be found at the end of each example page.

US Elections Obama vs Romney 2012

0
0

This example shows the results of the elections from 2012. The bars below the map show the results of each state.

Name Value Description
Region United States List with all available regions
Width auto Width of the map in pixel. 'Auto' means that the map is centered in the available width.
Height 400 Height of the map in pixel. 'Auto' means that the map is centered in the available height.
Display mode Regions Specifies the display mode of the map.
Border resolution Provinces The resolution of the map borders.
Tooltips On Allows to display a tooltip for highlighted map elements.
Tooltips: Trigger focus The user interaction that causes the tooltip to be displayed.
Tooltips: Use HTML Off Specifies if the tooltips should use HTML. This allows to customize the tooltips even more. For example, if this property is on, it is possible to display images wihtin the tooltip.
CSS
#{cssid} {
 overflow: hidden; 
}
#{cssid} .bar_container {
   margin: 10px auto;
  width: 200px;
}
#{cssid} .bars {
   margin: 5px 0;
   width: 200px;
  margin-right: 60px;
  clear: both;
}
#{cssid} .bar_body {
   border-radius: 5px;
   background-color: #dddddd;
   float: left;
   min-width: 20px;
}
#{cssid} .bar_number {
   float: right;
   width: 50px;
  margin-right:-60px;
}
#{cssid} .bar_number, #{cssid} .bar_body {
   height: 30px;
   line-height: 30px;
   vertical-align: middle;
}
#{cssid} .unit {
 white-space: nowrap; 
}
HTML
<div id="{cssid}">
  %%map%%
  <div class="bar_container">
    <div class="bars" id="bar1">
      <div class="bar_caption"> </div>
      <div class="bar_body"></div>
      <div class="bar_number"><span class="number">0</span><span class="unit"></span></div>
    </div>
    <div class="bars" id="bar2">
      <div class="bar_caption"> </div>
      <div class="bar_body"></div>
      <div class="bar_number"><span class="number">0</span><span class="unit"></span></div>
    </div>
  </div>
</div>

<script type='text/javascript'>
  (function($) {
      $.fn.countTo = function(options) {
          // merge the default plugin settings with the custom options
          options = $.extend({}, $.fn.countTo.defaults, options || {});

          // how many times to update the value, and how much to increment the value on each update
          var loops = Math.ceil(options.speed / options.refreshInterval),
              increment = (options.to - options.from) / loops;

          return $(this).each(function() {
              var _this = this,
                  loopCount = 0,
                  value = options.from,
                  interval = setInterval(updateTimer, options.refreshInterval);

              function updateTimer() {
                  value += increment;
                  loopCount++;
                  $(_this).html(value.toFixed(options.decimals));

                  if (typeof(options.onUpdate) == 'function') {
                      options.onUpdate.call(_this, value);
                  }

                  if (loopCount >= loops) {
                      clearInterval(interval);
                      value = options.to;

                      if (typeof(options.onComplete) == 'function') {
                          options.onComplete.call(_this, value);
                      }
                  }
              }
          });
      };

      $.fn.countTo.defaults = {
          from: 0,  // the number the element should start at
          to: 100,  // the number the element should end at
          speed: 1000,  // how long it should take to count between the target numbers
          refreshInterval: 100,  // how often the element should be updated
          decimals: 0,  // the number of decimal places to show
          onUpdate: null,  // callback method for every time the element is updated,
          onComplete: null,  // callback method for when the element finishes updating
      };
  })(jQuery);
</script>

JavaScript

Executed when a marker/region is clicked.

Click value can be defined for each map element.

if(map_storage==null) {
  var min = {};
  var max = {};
  jQuery.each(click_values, function(j,click_value) {
    var _min = min, _max = max;
    var split = click_value.split("\n");
	jQuery.each(split, function(k,v) {
      var params = eval("["+v+"]");
      if(typeof params[1] !== "undefined") {
        var group_key = "group"+params[2];
        if(typeof _min[group_key] == "undefined" || params[1]<_min[group_key]) _min[group_key] = params[1];
        if(typeof _max[group_key] == "undefined" || _max[group_key]<params[1]) _max[group_key] = params[1];
      }
    });
  });
  map_storage={min: min, max: max};
  console.log(map_storage);
}

var split = click_value.split("\n");
jQuery.each(split, function(j,v) {
  
  var params = eval("["+v+"]");
  var group_key = "group"+params[2];
  var min = map_storage["min"][group_key], max = map_storage["max"][group_key];
  var no = j+1;
  var element   = jQuery("#bar"+no).find(".number");
  var old_value = parseInt(element.text());
  element.stop().countTo({from: old_value, to: params[1], speed: 500, refreshInterval: 100});
  //if(params[1]>100) params[1]=100;
  //if(params[1]<0)   params[1]=0;
  params[1] = (params[1]-min) / (max - min) * 100;
  jQuery("#bar"+no).find(".bar_caption").text(params[0]);
  jQuery("#bar"+no).find(".unit").text(params[2]);
  jQuery("#bar"+no).find(".bar_body").stop().animate({width: params[1]+"%"},500);
  jQuery("#bar"+no).find(".bar_body").css("backgroundColor", params[3]);
});
Color Name Click Value
US-TX "Obama",41.38,"%","#004276" "Romney",57.17,"%","#b80000"
US-LA "Obama",40.58,"%","#004276" "Romney",57.78,"%","#b80000"
US-OK "Obama",33.23,"%","#004276" "Romney",66.77,"%","#b80000"
US-AR "Obama",36.88,"%","#004276" "Romney",60.57,"%","#b80000"
US-MS "Obama",43.79,"%","#004276" "Romney",55.29,"%","#b80000"
US-KS "Obama",37.99,"%","#004276" "Romney",59.71,"%","#b80000"
US-NE "Obama",38.03,"%","#004276" "Romney",59.80,"%","#b80000"
US-SD "Obama",39.87,"%","#004276" "Romney",57.89,"%","#b80000"
US-ND "Obama",38.69,"%","#004276" "Romney",58.32,"%","#b80000"
US-WY "Obama",27.82,"%","#004276" "Romney",68.64,"%","#b80000"
US-MT "Obama",41.70,"%","#004276" "Romney",55.35,"%","#b80000"
US-ID "Obama",32.62,"%","#004276" "Romney",64.53,"%","#b80000"
US-UT "Obama",24.75,"%","#004276" "Romney",72.79,"%","#b80000"
US-AZ "Obama",44.59,"%","#004276" "Romney",53.65,"%","#b80000"
US-AK "Obama",40.81,"%","#004276" "Romney",54.80,"%","#b80000"
US-AL "Obama",38.36,"%","#004276" "Romney",60.55,"%","#b80000"
US-GA "Obama",45.48,"%","#004276" "Romney",53.30,"%","#b80000"
US-SC "Obama",44.09,"%","#004276" "Romney",54.56,"%","#b80000"
US-NC "Obama",48.35,"%","#004276" "Romney",50.39,"%","#b80000"
US-TN "Obama",39.08,"%","#004276" "Romney",59.48,"%","#b80000"
US-KY "Obama",37.80,"%","#004276" "Romney",60.49,"%","#b80000"
US-IN "Obama",43.93,"%","#004276" "Romney",54.13,"%","#b80000"
US-WV "Obama",35.54,"%","#004276" "Romney",62.30,"%","#b80000"
US-HI "Obama",70.55,"%","#004276" "Romney",27.84,"%","#b80000"
US-FL "Obama",50.01,"%","#004276" "Romney",49.13,"%","#b80000"
US-CA "Obama",60.24,"%","#004276" "Romney",37.12,"%","#b80000"
US-NV "Obama",52.36,"%","#004276" "Romney",45.68,"%","#b80000"
US-NM "Obama",52.99,"%","#004276" "Romney",42.84,"%","#b80000"
US-CO "Obama",51.49,"%","#004276" "Romney",46.13,"%","#b80000"
US-IL "Obama",57.60,"%","#004276" "Romney",40.73,"%","#b80000"
US-MO "Obama",44.38,"%","#004276" "Romney",53.76,"%","#b80000"
US-WI "Obama",52.83,"%","#004276" "Romney",45.89,"%","#b80000"
US-IA "Obama",51.99,"%","#004276" "Romney",46.18,"%","#b80000"
US-MN "Obama",52.65,"%","#004276" "Romney",44.96,"%","#b80000"
US-OH "Obama",50.67,"%","#004276" "Romney",47.69,"%","#b80000"
US-WA "Obama",56.16,"%","#004276" "Romney",41.29,"%","#b80000"
US-OR "Obama",54.24,"%","#004276" "Romney",42.15,"%","#b80000"
US-VA "Obama",51.16,"%","#004276" "Romney",47.28,"%","#b80000"
US-PA "Obama",51.97,"%","#004276" "Romney",46.59,"%","#b80000"
US-MI "Obama",54.21,"%","#004276" "Romney",44.71,"%","#b80000"
US-NY "Obama",63.35,"%","#004276" "Romney",35.17,"%","#b80000"
US-ME "Obama",56.27,"%","#004276" "Romney",40.98,"%","#b80000"
US-VT "Obama",66.57,"%","#004276" "Romney",30.97,"%","#b80000"
US-MA "Obama",60.65,"%","#004276" "Romney",37.51,"%","#b80000"
US-NH "Obama",51.98,"%","#004276" "Romney",46.40,"%","#b80000"
US-MD "Obama",61.97,"%","#004276" "Romney",35.90,"%","#b80000"
US-NJ "Obama",58.38,"%","#004276" "Romney",40.59,"%","#b80000"
US-RI "Obama",62.70,"%","#004276" "Romney",35.24,"%","#b80000"
US-CT "Obama",58.06,"%","#004276" "Romney",40.73,"%","#b80000"
US-DE "Obama",58.61,"%","#004276" "Romney",39.98,"%","#b80000"
US-DC "Obama",90.91,"%","#004276" "Romney",7.28,"%","#b80000"

Comments

If you need help or have questions, please leave a comment.


Search

Responsive? Yes!

Our maps are fully responsive. They automatically fit into the available width. Try it by resizing your browser window.

Did you know…

  • All examples are importable to your plugin.
  • We extend our set of examples from time to time. If you think there is an example missing, write us a message and we will try to add it!

User reviews

  • Best map-plugin I could find.
  • Great support. Real fast response. This was exactly what I needed. Very flexible and useful.
  • Was waiting for plugin like this for ages! Customer support is also great.
  • Customer support is excellent and very quick. I have no hesitation in recommending this product.

Example for a sidebar map


All maps can also easily be added to your sidebar.