googlemap.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <html>
  2. <head>
  3. <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true&amp;key=AIzaSyC0PBI1vQBjdAcNST1_c47zOGtkIFXK5u8" type="text/javascript"></script>
  4. <script type="text/javascript">
  5. var queryString = window.location.search.substring(1)
  6. queryString = queryString.split('&');
  7. x = queryString[0].split('=');
  8. map_x = x[1];
  9. y = queryString[1].split('=');
  10. map_y = y[1];
  11. z = queryString[2].split('=');
  12. map_z = z[1];
  13. if(queryString[3] != undefined){
  14. img = queryString[3].split('=');
  15. img = img[1] ? '<img src="' + img[1] + '" />' : 'Click and then move the icon to your store location';
  16. }else{
  17. img = 'Click and then move the icon to your store location';
  18. }
  19. window.onload = function(){
  20. setinitialize(map_x, map_y, map_z, img);
  21. }
  22. function pointarrow(coor, zoom) {
  23. var cx = "";
  24. var cy = "";
  25. stopx = false;
  26. for (x = 0; x <= coor.length; x++) {
  27. if (stopx == false) {
  28. cx = cx+coor.charAt(x);
  29. }
  30. if (coor.charAt(x) == ",") {
  31. stopx = true;
  32. }
  33. if (stopx == true) {
  34. cy = cy+coor.charAt(x);
  35. }
  36. }
  37. cx = cx.substr(0, cx.length-1);
  38. cy = cy.substr(1, cy.length);
  39. el = window.parent.document.getElementsByClassName('latitude')[0];
  40. el.getElementsByTagName('input')[0].value = cx;
  41. el = window.parent.document.getElementsByClassName('longitude')[0];
  42. el.getElementsByTagName('input')[0].value = cy;
  43. el = window.parent.document.getElementsByClassName('zoom')[0];
  44. el.getElementsByTagName('input')[0].value = zoom;
  45. }
  46. </script>
  47. <script type="text/javascript">
  48. function setinitialize(the_x, the_y, the_z, the_img) {
  49. if (GBrowserIsCompatible()) {
  50. if(the_x != '' && the_y != '' && the_z != ''){
  51. var map = new GMap2(document.getElementById("map_canvas"));
  52. var contentString = the_img;
  53. map.setCenter(new GLatLng(the_x, the_y), parseInt(the_z));
  54. map.openInfoWindow(map.getCenter(), contentString);
  55. map.setUIToDefault();
  56. var point = new GLatLng(the_x, the_y);
  57. var marker = new GMarker(point, {draggable: true});
  58. map.openInfoWindow(map.getCenter(), contentString);
  59. GEvent.addListener(marker, "dragstart", function() {
  60. map.closeInfoWindow();
  61. });
  62. GEvent.addListener(marker, "dragend", function() {
  63. var location = marker.getLatLng().toUrlValue(5);
  64. marker.openInfoWindowHtml(contentString);
  65. pointarrow(location, map.getZoom());
  66. });
  67. map.addOverlay(marker);
  68. GEvent.addListener(map,"zoomend",function() {
  69. var location = marker.getLatLng().toUrlValue(5);
  70. pointarrow(location, map.getZoom());
  71. });
  72. }else{
  73. var map = new GMap2(document.getElementById("map_canvas"));
  74. map.setCenter(new GLatLng(14.58408, 120.99981), 13);
  75. map.setUIToDefault();
  76. var point = new GLatLng(14.58408, 120.99981);
  77. var marker = new GMarker(point, {draggable: true});
  78. map.openInfoWindow(map.getCenter(), document.createTextNode("Click and then move the icon to your store location"));
  79. GEvent.addListener(marker, "dragstart", function() {
  80. map.closeInfoWindow();
  81. });
  82. GEvent.addListener(marker, "dragend", function() {
  83. var location = marker.getLatLng().toUrlValue(5);
  84. //marker.openInfoWindowHtml("Your store location is at " + location);
  85. pointarrow(location, map.getZoom());
  86. });
  87. map.addOverlay(marker);
  88. GEvent.addListener(map,"zoomend",function() {
  89. var location = marker.getLatLng().toUrlValue(5);
  90. pointarrow(location, map.getZoom());
  91. });
  92. }
  93. }
  94. }
  95. </script>
  96. </head>
  97. <body onUnload="GUnload()">
  98. <div id="map_canvas" style="width:100%; height:99%; border: 2px solid #666;"></div>
  99. </body>
  100. </html>