google.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. $(function () {
  2. //Basic Map
  3. var basicMap = new GMaps({
  4. el: '#gmap_basic_example',
  5. lat: -12.043333,
  6. lng: -77.028333
  7. });
  8. //Markers
  9. var markers = new GMaps({
  10. div: '#gmap_markers',
  11. lat: -12.043333,
  12. lng: -77.028333
  13. });
  14. markers.addMarker({
  15. lat: -12.043333,
  16. lng: -77.03,
  17. title: 'Lima',
  18. details: {
  19. database_id: 42,
  20. author: 'HPNeo'
  21. },
  22. click: function (e) {
  23. if (console.log)
  24. console.log(e);
  25. alert('You clicked in this marker');
  26. }
  27. });
  28. markers.addMarker({
  29. lat: -12.042,
  30. lng: -77.028333,
  31. title: 'Marker with InfoWindow',
  32. infoWindow: {
  33. content: '<p>HTML Content</p>'
  34. }
  35. });
  36. //Static maps
  37. var staticMap = GMaps.staticMapURL({
  38. size: [$('#gmap_static_map').width(), 400],
  39. lat: -12.043333,
  40. lng: -77.028333
  41. });
  42. $('<img/>').attr('src', staticMap).appendTo('#gmap_static_map');
  43. //Static maps with markers
  44. var staticMapWithMarkers = GMaps.staticMapURL({
  45. size: [$('#gmap_static_map_with_markers').width(), 400],
  46. lat: -12.043333,
  47. lng: -77.028333,
  48. markers: [
  49. { lat: -12.043333, lng: -77.028333 },
  50. {
  51. lat: -12.045333, lng: -77.034,
  52. size: 'small'
  53. },
  54. {
  55. lat: -12.045633, lng: -77.022,
  56. color: 'blue'
  57. }
  58. ]
  59. });
  60. $('<img/>').attr('src', staticMapWithMarkers).appendTo('#gmap_static_map_with_markers');
  61. //Static maps with polyline
  62. var path = [
  63. [-12.040397656836609, -77.03373871559225],
  64. [-12.040248585302038, -77.03993927003302],
  65. [-12.050047116528843, -77.02448169303511],
  66. [-12.044804866577001, -77.02154422636042],
  67. [-12.040397656836609, -77.03373871559225],
  68. ];
  69. var staticMapPolyline = GMaps.staticMapURL({
  70. size: [$('#gmap_static_map_polyline').width(), 400],
  71. lat: -12.043333,
  72. lng: -77.028333,
  73. polyline: {
  74. path: path,
  75. strokeColor: '#131540',
  76. strokeOpacity: 0.6,
  77. strokeWeight: 6
  78. // fillColor: '#ffaf2ecc'
  79. }
  80. });
  81. $('<img/>').attr('src', staticMapPolyline).appendTo('#gmap_static_map_polyline');
  82. //Panorama
  83. var panorama = GMaps.createPanorama({
  84. el: '#gmap_panorama',
  85. lat: 42.3455,
  86. lng: -71.0983
  87. });
  88. });