Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> problem z wygenerowaniem kml
myro6
post
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 18.08.2011

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


Witam wszystkich próbuje zrobić plik kml za pomocą przykładowego kodu z Google Earth, zawartość pliku jest poprawna jednak marker nie otwiera się w programie problem polega na tym że plik kml zaczyna się od trzeciego a nie pierwszego wiersza, używam krasnal serv. Jeśli ktoś wie co jest nie tak będę wdzięczny za pomoc
  1. <?php
  2.  
  3. header('Content-type: application/vnd.google-earth.kml+xml');
  4. require('phpsqlajax_dbinfo.php');
  5. // Opens a connection to a MySQL server.
  6. $connection = mysql_connect ($server, $username, $password);
  7. if (!$connection)
  8. {
  9. die('Not connected : ' . mysql_error());
  10. }
  11.  
  12. // Sets the active MySQL database.
  13. $db_selected = mysql_select_db($database, $connection);
  14. if (!$db_selected)
  15. {
  16. die ('Can\'t use db : ' . mysql_error());
  17. }
  18.  
  19. // Selects all the rows in the markers table.
  20. $query = 'SELECT * FROM markers WHERE 1';
  21. $result = mysql_query($query);
  22. if (!$result)
  23. {
  24. die('Invalid query: ' . mysql_error());
  25. }
  26. // Creates an array of strings to hold the lines of the KML file.
  27. $kml = array('<?xml version="1.0" encoding="UTF-8"?>');
  28. $kml[] = '<kml xmlns="http://earth.google.com/kml/2.1">';
  29. $kml[] = ' <Document>';
  30. $kml[] = ' <Style id="restaurantStyle">';
  31. $kml[] = ' <IconStyle id="restuarantIcon">';
  32. $kml[] = ' <Icon>';
  33. $kml[] = ' <href>http://maps.google.com/mapfiles/kml/pal2/icon63.png</href>';
  34. $kml[] = ' </Icon>';
  35. $kml[] = ' </IconStyle>';
  36. $kml[] = ' </Style>';
  37. $kml[] = ' <Style id="barStyle">';
  38. $kml[] = ' <IconStyle id="barIcon">';
  39. $kml[] = ' <Icon>';
  40. $kml[] = ' <href>http://maps.google.com/mapfiles/kml/pal2/icon27.png</href>';
  41. $kml[] = ' </Icon>';
  42. $kml[] = ' </IconStyle>';
  43. $kml[] = ' </Style>';
  44.  
  45. // Iterates through the rows, printing a node for each row.
  46. while ($row = @mysql_fetch_assoc($result))
  47. {
  48. $kml[] = ' <Placemark id="placemark' . $row['id'] . '">';
  49. $kml[] = ' <name>' . htmlentities($row['name']) . '</name>';
  50. $kml[] = ' <description>' . htmlentities($row['address']) . '</description>';
  51. $kml[] = ' <styleUrl>#' . ($row['type']) .'Style</styleUrl>';
  52. $kml[] = ' <Point>';
  53. $kml[] = ' <coordinates>' . $row['lng'] . ',' . $row['lat'] . '</coordinates>';
  54. $kml[] = ' </Point>';
  55. $kml[] = ' </Placemark>';
  56.  
  57. }
  58.  
  59. // End XML file
  60. $kml[] = ' </Document>';
  61. $kml[] = '</kml>';
  62. $kmlOutput = join($kml ,"\n");
  63. //header('Content-type: application/vnd.google-earth.kml+xml');
  64. echo $kmlOutput;
  65.  
  66. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 21.08.2025 - 18:41