gmaps.init.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* global GMaps: true */
  2. $(document).ready(function () {
  3. map()
  4. })
  5. function map () {
  6. if ($('#map').length) {
  7. var lat = $('#gmap-lat').val()
  8. var lng = $('#gmap-lng').val()
  9. var direction = $('#gmap-dir').val()
  10. var image = $('#gmap-marker').val()
  11. var styles =
  12. [
  13. {
  14. 'featureType': 'landscape', 'stylers': [{'saturation': -100}, {'lightness': 65}, {'visibility': 'on'}]
  15. }, {
  16. 'featureType': 'poi', 'stylers': [{'saturation': -100}, {'lightness': 51}, {'visibility': 'simplified'}]
  17. }, {
  18. 'featureType': 'road.highway', 'stylers': [{'saturation': -100}, {'visibility': 'simplified'}]
  19. }, {
  20. 'featureType': 'road.arterial', 'stylers': [{'saturation': -100}, {'lightness': 30}, {'visibility': 'on'}]
  21. }, {
  22. 'featureType': 'road.local', 'stylers': [{'saturation': -100}, {'lightness': 40}, {'visibility': 'on'}]
  23. }, {
  24. 'featureType': 'transit', 'stylers': [{'saturation': -100}, {'visibility': 'simplified'}]
  25. }, {
  26. 'featureType': 'administrative.province', 'stylers': [{'visibility': 'off'}]
  27. }, {
  28. 'featureType': 'water', 'elementType': 'labels', 'stylers': [{'visibility': 'on'}, {'lightness': -25}, {'saturation': -100}]
  29. }, {
  30. 'featureType': 'water', 'elementType': 'geometry', 'stylers': [{'hue': '#ffff00'}, {'lightness': -25}, {'saturation': -97}]
  31. }
  32. ]
  33. var map = new GMaps({
  34. el: '#map',
  35. lat: lat,
  36. lng: lng,
  37. zoomControl: true,
  38. zoomControlOpt: {
  39. style: 'SMALL',
  40. position: 'TOP_LEFT'
  41. },
  42. panControl: false,
  43. streetViewControl: false,
  44. mapTypeControl: false,
  45. overviewMapControl: false,
  46. scrollwheel: false,
  47. draggable: false,
  48. styles: styles
  49. })
  50. map.addMarker({
  51. lat: lat,
  52. lng: lng,
  53. icon: image,
  54. click: function (e) {
  55. // when we get an address with spaces ...
  56. var url = 'https://maps.google.com?daddr=' + direction.split('match').join('replace')
  57. window.open(url, '_blank')
  58. },
  59. title: direction
  60. /* ,
  61. infoWindow: {
  62. content: '<p>HTML Content</p>'
  63. } */
  64. })
  65. }
  66. }