maps-vector.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. var MapsVector = function () {
  2. var setMap = function (name) {
  3. var data = {
  4. map: 'world_en',
  5. backgroundColor: null,
  6. borderColor: '#333333',
  7. borderOpacity: 0.5,
  8. borderWidth: 1,
  9. color: '#c6c6c6',
  10. enableZoom: true,
  11. hoverColor: '#c9dfaf',
  12. hoverOpacity: null,
  13. values: sample_data,
  14. normalizeFunction: 'linear',
  15. scaleColors: ['#b6da93', '#427d1a'],
  16. selectedColor: '#c9dfaf',
  17. selectedRegion: null,
  18. showTooltip: true,
  19. onRegionOver: function (event, code) {
  20. //sample to interact with map
  21. if (code == 'ca') {
  22. event.preventDefault();
  23. }
  24. },
  25. onRegionClick: function (element, code, region) {
  26. //sample to interact with map
  27. var message = 'You clicked "' + region + '" which has the code: ' + code.toUpperCase();
  28. alert(message);
  29. }
  30. };
  31. data.map = name + '_en';
  32. var map = jQuery('#vmap_' + name);
  33. if (!map) {
  34. return;
  35. }
  36. map.width(map.parent().width());
  37. map.vectorMap(data);
  38. }
  39. return {
  40. //main function to initiate map samples
  41. init: function () {
  42. setMap("world");
  43. setMap("usa");
  44. setMap("europe");
  45. setMap("russia");
  46. setMap("germany");
  47. // redraw maps on window or content resized
  48. App.addResponsiveHandler(function(){
  49. setMap("world");
  50. setMap("usa");
  51. setMap("europe");
  52. setMap("russia");
  53. setMap("germany");
  54. });
  55. }
  56. };
  57. }();