Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][JavaScript] markery na mapie google
blizniak
post
Post #1





Grupa: Zarejestrowani
Postów: 253
Pomógł: 0
Dołączył: 14.04.2005

Ostrzeżenie: (0%)
-----


  1. //pokaz na mapie
  2. if($_POST["sposob_wyswietlania"]==2)
  3.  {
  4.    //echo "mapa";    
  5.        
  6. ?>        
  7. <script type="text/javascript">
  8. //<![CDATA[
  9.  
  10.  
  11. var map = new GMap(document.getElementById("map2"));
  12. map.addControl(new GLargeMapControl());
  13. map.addControl(new GMapTypeControl());
  14. map.addControl(new GScaleControl());
  15. map.setCenter(new GLatLng(51.512161, -0.14110), 11, G_NORMAL_MAP);
  16.  
  17. // Creates a marker whose info window displays the given number
  18. function createMarker(point, number)
  19. {
  20.  var marker = new GMarker(point);
  21.  // Show this markers index in the info window when it is clicked
  22.  var html =  number;
  23.  GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
  24.  return marker;
  25. };
  26.  
  27. var point = new GLatLng(51.513156,-0.131396);
  28. var marker = createMarker(point, 'Track Records office, Old Compton Street');
  29. map.addOverlay(marker);
  30.  
  31. //]]>
  32.  
  33. <?
  34.  
  35.    $result = mysql_query("SELECT id, miasto, lat, lng data_dod FROM advert_have  Where miasto=732 ORDER BY data_dod desc");
  36.  
  37.    
  38.    if (!$result)
  39.     {
  40.       echo "no results ";
  41.     }
  42.    while($row = mysql_fetch_array($result))
  43.     {
  44.       echo "var point = new GLatLng(" . $row['lat'] . "," . $row['lng'] . ");\n";
  45.       echo "var marker = createMarker(point, '" . addslashes($row['data_dod']) . "');\n";
  46.       echo "map.addOverlay(marker);\n";
  47.       echo "\n";
  48.     }
  49.  
  50.    ?>
  51.         </script>        
  52. <?
  53.    echo '<div id="map2" style="width: 500px; height: 300px"></div>';    
  54.  }

problem jest w tym ze wyniki z bazy mysql nie wyswietlaja sie na mapie
jesli usune powyzszy kod php i zostawie w js
  1. var point = new GLatLng(51.513156,-0.131396);
  2. var marker = createMarker(point, 'Track Records office, Old Compton Street');
  3. map.addOverlay(marker);

to punkt ten jest pokazany na mapie

natomiast gdy dodam ten powyzszy kod php z petla to nie wyswietla mi sie nawet pusta mapka
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 12:00