touch_detect.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <title>JQVMap - Europe Map</title>
  6. <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  7. <link href="../dist/jqvmap.css" media="screen" rel="stylesheet" type="text/css">
  8. <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
  9. <script type="text/javascript" src="../dist/jquery.vmap.js"></script>
  10. <script type="text/javascript" src="../dist/maps/jquery.vmap.europe.js" charset="utf-8"></script>
  11. <script type="text/javascript">
  12. function touch_detect() {
  13. return 'ontouchstart' in window || 'onmsgesturechange' in window || navigator.msMaxTouchPoints > 0;
  14. }
  15. jQuery(document).ready(function () {
  16. jQuery('#vmap').vectorMap({
  17. map: 'europe_en',
  18. enableZoom: false,
  19. showTooltip: false,
  20. onRegionClick: function (element, code, region) {
  21. if (!touch_detect()) {
  22. // we're not on a mobile device, handle the click
  23. var message = 'You clicked "' + region + '" which has the code: ' + code.toUpperCase();
  24. alert(message);
  25. }
  26. },
  27. onRegionOver: function (element, code, region) {
  28. if (touch_detect()) {
  29. /// we're not on a mobile device, handle the click
  30. var message = 'You clicked "' + region + '" which has the code: ' + code.toUpperCase();
  31. alert(message);
  32. }
  33. }
  34. });
  35. });
  36. </script>
  37. </head>
  38. <body>
  39. <div id="vmap" style="width: 680px; height: 520px;"></div>
  40. </body>
  41. </html>