Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

map-script.js 4.6KB

2 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* --------------------------------------------
  2. Google Map
  3. -------------------------------------------- */
  4. window.onload = MapLoadScript;
  5. function GmapInit() {
  6. Gmap = $('.map-canvas');
  7. Gmap.each(function() {
  8. var $this = $(this),
  9. lat = '',
  10. lng = '',
  11. zoom = 12,
  12. scrollwheel = false,
  13. zoomcontrol = true,
  14. draggable = true,
  15. mapType = google.maps.MapTypeId.ROADMAP,
  16. title = '',
  17. contentString = '',
  18. theme_icon_path = $this.data('icon-path'),
  19. dataLat = $this.data('lat'),
  20. dataLng = $this.data('lng'),
  21. dataZoom = $this.data('zoom'),
  22. dataType = $this.data('type'),
  23. dataScrollwheel = $this.data('scrollwheel'),
  24. dataZoomcontrol = $this.data('zoomcontrol'),
  25. dataHue = $this.data('hue'),
  26. dataTitle = $this.data('title'),
  27. dataContent = $this.data('content');
  28. if( dataZoom !== undefined && dataZoom !== false ) {
  29. zoom = parseFloat(dataZoom);
  30. }
  31. if( dataLat !== undefined && dataLat !== false ) {
  32. lat = parseFloat(dataLat);
  33. }
  34. if( dataLng !== undefined && dataLng !== false ) {
  35. lng = parseFloat(dataLng);
  36. }
  37. if( dataScrollwheel !== undefined && dataScrollwheel !== null ) {
  38. scrollwheel = dataScrollwheel;
  39. }
  40. if( dataZoomcontrol !== undefined && dataZoomcontrol !== null ) {
  41. zoomcontrol = dataZoomcontrol;
  42. }
  43. if( dataType !== undefined && dataType !== false ) {
  44. if( dataType == 'satellite' ) {
  45. mapType = google.maps.MapTypeId.SATELLITE;
  46. } else if( dataType == 'hybrid' ) {
  47. mapType = google.maps.MapTypeId.HYBRID;
  48. } else if( dataType == 'terrain' ) {
  49. mapType = google.maps.MapTypeId.TERRAIN;
  50. }
  51. }
  52. if( dataTitle !== undefined && dataTitle !== false ) {
  53. title = dataTitle;
  54. }
  55. if( navigator.userAgent.match(/iPad|iPhone|Android/i) ) {
  56. draggable = false;
  57. }
  58. var mapOptions = {
  59. zoom : zoom,
  60. scrollwheel : scrollwheel,
  61. zoomControl : zoomcontrol,
  62. draggable : draggable,
  63. center : new google.maps.LatLng(lat, lng),
  64. mapTypeId : mapType
  65. };
  66. var map = new google.maps.Map($this[0], mapOptions);
  67. //var image = 'images/icons/map-marker.png';
  68. var image = theme_icon_path;
  69. if( dataContent !== undefined && dataContent !== false ) {
  70. contentString = '<div class="map-data">' + '<h6>' + title + '</h6>' + '<div class="map-content">' + dataContent + '</div>' + '</div>';
  71. }
  72. var infowindow = new google.maps.InfoWindow({
  73. content: contentString
  74. });
  75. var marker = new google.maps.Marker({
  76. position : new google.maps.LatLng(lat, lng),
  77. map : map,
  78. icon : image,
  79. title : title
  80. });
  81. if( dataContent !== undefined && dataContent !== false ) {
  82. google.maps.event.addListener(marker, 'click', function() {
  83. infowindow.open(map,marker);
  84. });
  85. }
  86. if( dataHue !== undefined && dataHue !== false ) {
  87. var styles = [
  88. {
  89. "featureType": "administrative",
  90. "elementType": "labels.text.fill",
  91. "stylers": [
  92. {
  93. "color": "#444444"
  94. }
  95. ]
  96. },
  97. {
  98. "featureType": "landscape",
  99. "elementType": "all",
  100. "stylers": [
  101. {
  102. "color": "#f2f2f2"
  103. }
  104. ]
  105. },
  106. {
  107. "featureType": "poi",
  108. "elementType": "all",
  109. "stylers": [
  110. {
  111. "visibility": "off"
  112. }
  113. ]
  114. },
  115. {
  116. "featureType": "road",
  117. "elementType": "all",
  118. "stylers": [
  119. {
  120. "saturation": -100
  121. },
  122. {
  123. "lightness": 45
  124. }
  125. ]
  126. },
  127. {
  128. "featureType": "road.highway",
  129. "elementType": "all",
  130. "stylers": [
  131. {
  132. "visibility": "simplified"
  133. }
  134. ]
  135. },
  136. {
  137. "featureType": "road.arterial",
  138. "elementType": "labels.icon",
  139. "stylers": [
  140. {
  141. "visibility": "off"
  142. }
  143. ]
  144. },
  145. {
  146. "featureType": "transit",
  147. "elementType": "all",
  148. "stylers": [
  149. {
  150. "visibility": "off"
  151. }
  152. ]
  153. },
  154. {
  155. "featureType": "water",
  156. "elementType": "all",
  157. "stylers": [
  158. {
  159. "color": "#13b5ea"
  160. },
  161. {
  162. "visibility": "on"
  163. }
  164. ]
  165. }
  166. ];
  167. map.setOptions({styles: styles});
  168. }
  169. });
  170. }
  171. function MapLoadScript() {
  172. var script = document.createElement('script');
  173. script.type = 'text/javascript';
  174. GmapInit();
  175. document.body.appendChild(script);
  176. }