Advertisement
Guest User

Untitled

a guest
Jan 31st, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. var geocoder;
  2. var prevHover;
  3. var curCountry;
  4. var created = false;
  5. var worldGeometry;
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. function highlightCountry(country) {
  15. var text = "ISO_2DIGIT IN ('" + String(curCountry) + "')";
  16. worldGeometry.setOptions({
  17. query: {
  18. select: 'geometry',
  19. from: '1N2LBk4JHwWpOY4d9fobIn27lfnZ5MDy-NoqqRpk',
  20. where: text
  21. }
  22. })
  23.  
  24.  
  25. }
  26.  
  27. function getCountry(latLng) {
  28. geocoder.geocode({ 'latLng': latLng },
  29. function (results, status) {
  30. if (status == google.maps.GeocoderStatus.OK) {
  31. if (results[0]) {
  32. for (var i = 0; i < results[0].address_components.length; i++) {
  33. if (results[0].address_components[i].types[0] == "country") {
  34. curCountry = results[0].address_components[i].short_name;
  35. }
  36. }
  37. }
  38. else {
  39. //didn't find anything
  40. }
  41. }
  42. }
  43. );
  44. }
  45.  
  46. google.maps.event.addListener(map, 'click', function (event) {
  47. getCountry(event.latLng);
  48. });
  49.  
  50. google.maps.event.addListener(map, 'mousemove', function (event) {
  51. getCountry(event.latLng);
  52. highlightCountry(curCountry);
  53. });
  54.  
  55. google.maps.event.addListenerOnce(map, 'idle', function () {
  56. getCountry(map.getCenter());
  57. var center = "ISO_2DIGIT IN ('" + curCountry + "')";
  58. worldGeometry = new google.maps.FusionTablesLayer({
  59. query: {
  60. select: 'geometry',
  61. from: '1N2LBk4JHwWpOY4d9fobIn27lfnZ5MDy-NoqqRpk',
  62. where: center
  63.  
  64. },
  65. map: map,
  66. suppressInfoWindows: true
  67. });
  68. google.maps.event.addListener(worldGeometry, 'click', function (event) {
  69. getCountry(event.latLng);
  70. });
  71.  
  72.  
  73. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement