Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: skrypt do mapki za google z geolokalizacją
Forum PHP.pl > Forum > Gotowe rozwiązania
toolmaniak
Witam, wypalam po woli kod moich statystyk i ostatnio wpadło mi do głowy, żeby urozmaicić go o jakąś mapkę wskazującą geolokalizacje (a konkretnie państwo) na mapie Europy lub wiata. Mój wybór padł na google.maps bo chyba posiadają najlepiej dopracowany aplecik do tego. No więc zarejestrowałem się, ściągłem klucz i podpiąłem pod taki kawałeczek kodziku jak poniżej:

  1. <script type="text/javascript" src="proxy.js"></script>
  2. <!-- ImageReady Preload Script (layout.psd) -->
  3. <script TYPE="text/javascript">
  4. <!--
  5.  
  6. function newImage(arg) {
  7. if (document.images) {
  8. rslt = new Image();
  9. rslt.src = arg;
  10. return rslt;
  11. }
  12. }
  13.  
  14. function changeImages() {
  15. if (document.images && (preloadFlag == true)) {
  16. for (var i=0; i<changeImages.arguments.length; i+=2) {
  17. document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
  18. }
  19. }
  20. }
  21.  
  22. var preloadFlag = false;
  23. function preloadImages() {
  24. if (document.images) {
  25. Button1_over = newImage("images/Button1-over.gif");
  26. Button2_Button1_over = newImage("images/Button2-Button1_over.gif");
  27. Button2_over = newImage("images/Button2-over.gif");
  28. Button3_Button2_over = newImage("images/Button3-Button2_over.gif");
  29. Button3_over = newImage("images/Button3-over.gif");
  30. Button4_Button3_over = newImage("images/Button4-Button3_over.gif");
  31. Button4_over = newImage("images/Button4-over.gif");
  32. Button5_Button4_over = newImage("images/Button5-Button4_over.gif");
  33. Button5_over = newImage("images/Button5-over.gif");
  34. Footer_button1_over = newImage("images/Footer_button1-over.gif");
  35. Footer_button2_Footer_button1_over = newImage("images/Footer_button2-Footer_butto.gif");
  36. Footer_button2_over = newImage("images/Footer_button2-over.gif");
  37. footer_button3_Footer_button2_over = newImage("images/footer_button3-Footer_butto.gif");
  38. footer_button3_over = newImage("images/footer_button3-over.gif");
  39. footer_button4_footer_button3_over = newImage("images/footer_button4-footer_butto.gif");
  40. footer_button4_over = newImage("images/footer_button4-over.gif");
  41. footer_button5_footer_button4_over = newImage("images/footer_button5-footer_butto.gif");
  42. footer_button5_over = newImage("images/footer_button5-over.gif");
  43. preloadFlag = true;
  44. }
  45. }
  46.  
  47. // -->
  48. <!-- End Preload Script -->
  49. <link href="style.css" rel="stylesheet" type="text/css">
  50. </HEAD>
  51. <BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 ONLOAD="preloadImages(); onload();">
  52. <!-- ImageReady Slices (layout.psd) -->
  53. <!-- SiteSearch Google -->
  54.  
  55.  
  56. <script type="text/javascript"><!--
  57. google_ad_client = "pub-7304917892182792";
  58. google_ad_width = 468;
  59. google_ad_height = 15;
  60. google_ad_format = "468x15_0ads_al";
  61. google_ad_channel ="4861641801";
  62. google_color_border = "FFA013";
  63. google_color_bg = "FFFFFF";
  64. google_color_link = "980000";
  65. google_color_text = "006600";
  66. google_color_url = "FFA800";
  67. //--></script>
  68. <script type="text/javascript"
  69. src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  70.  
  71.  
  72.  
  73.  
  74.  
  75. <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAJzAXMS2InZxi2XjUHtDO8hQOFTMV00YHKbFUz59i_1oSM7yp7RTFipWNpVDr
    LrXvTFRyNKlKWxsEXA"
    type="text/javascript"></script>
  76. <div id="map" style="width: 450px; height: 300px; margin: 1px auto;"></div>
  77. <div id="message"></div>
  78. <script type="text/javascript">
  79. //<![CDATA[
  80. // A TextualZoomControl is a GControl that displays textual "Zoom In"
  81. // and "Zoom Out" buttons (as opposed to the iconic buttons used in
  82. // Google Maps).
  83. function TextualZoomControl() {
  84. }
  85. TextualZoomControl.prototype = new GControl();
  86.  
  87. // Creates a one DIV for each of the buttons and places them in a container
  88. // DIV which is returned as our control element. We add the control to
  89. // to the map container and return the element for the map class to
  90. // position properly.
  91. TextualZoomControl.prototype.initialize = function(map) {
  92. var container = document.createElement("div");
  93.  
  94. var zoomInDiv = document.createElement("div");
  95. this.setButtonStyle_(zoomInDiv);
  96. container.appendChild(zoomInDiv);
  97. zoomInDiv.appendChild(document.createTextNode("Zoom In (+)"));
  98. GEvent.addDomListener(zoomInDiv, "click", function() {
  99. map.zoomIn();
  100. });
  101.  
  102. var zoomOutDiv = document.createElement("div");
  103. this.setButtonStyle_(zoomOutDiv);
  104. container.appendChild(zoomOutDiv);
  105. zoomOutDiv.appendChild(document.createTextNode("Zoom Out (-)"));
  106. GEvent.addDomListener(zoomOutDiv, "click", function() {
  107. map.zoomOut();
  108. });
  109.  
  110. map.getContainer().appendChild(container);
  111. return container;
  112. }
  113.  
  114. // By default, the control will appear in the top left corner of the
  115. // map with 7 pixels of padding.
  116. TextualZoomControl.prototype.getDefaultPosition = function() {
  117. return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(4, 4));
  118. }
  119.  
  120. // Sets the proper CSS for the given button element.
  121. TextualZoomControl.prototype.setButtonStyle_ = function(button) {
  122. button.style.textDecoration = "underline";
  123. button.style.color = "#008800";
  124. button.style.backgroundColor = "#99B3CC";
  125. button.style.font = "9px Arial";
  126. button.style.border = "1px solid #88a9c9";
  127. button.style.padding = "1px";
  128. button.style.marginBottom = "1px";
  129. button.style.textAlign = "center";
  130. button.style.width = "8em";
  131. button.style.cursor = "pointer";
  132. }
  133. function onload() {
  134. var map = new GMap(document.getElementById("map"));
  135. map.disableDragging();
  136. map.addControl(new TextualZoomControl());
  137. map.addControl(new GMapTypeControl());
  138. map.centerAndZoom(new GPoint(20, 52), 15);
  139. var icon = new GIcon();
  140. icon.image = "http://labs.google.com/ridefinder/images/mm_19_red.png";
  141. icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
  142. icon.iconSize = new GSize(12, 20);
  143. icon.shadowSize = new GSize(22, 20);
  144. icon.iconAnchor = new GPoint(9, 20);
  145. map.addOverlay(new GMarker(new GPoint(20, 52), icon));
  146. }
  147. //]]>
  148. </script>


tam jest taka linijka jak: map.addOverlay(new GMarker(new GPoint(20, 52), icon)); która wskazuje na położenie geograficzne (współrzędną, południk - równoleżnik) ikonki zaznaczenia, i zależałoby mi na znalezieniu czegoś co mapowało by kod kraju który wyciagam z whois np. PL, DE, JP na właśnie szerokości geograficzne (jakaś ogólnie dostępna baza danych). Jest coś takiego? Z takiego jak powyżej skryptu korzysta min. http://www.ipaddresslocation.org tylko nie mam pojęcia jak oni to robią....questionmark.gifquestionmark.gif
toolmaniak
Spoko, czytałem już wcześniej ten pościk, z tym że bazy tam zamieszczone (jak sam autor napisał) działają tylko z klasą scout, a ja robie coś zupełnie innego...
nospor
no ale przy pomocy klasy mozesz pobierac interesujace ci informacje i korzystac z nich w "tym czyms innym" smile.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.