You're massively overcomplicating this.. Here's my PHP file that
produces JSON for all the markers I need to map.. Javascript on the
client side does the rest:
<?php
require 'killguest.php';
require 'db_connect.php';
$sth = mysql_query("SELECT id, speed, name as details, time, latitude
as lat, longitude as lng, category_id, crewname as code from
z_cached_locations");
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
echo json_encode($rows);
mysql_close();
?>
Duncan.
On Feb 3, 3:51 pm, guido Schmidt <[email protected]> wrote:
> I did manage to make a website with markers.
> The lat/ lng is stored in the database extra data is also in the database.
>
> A xml file is outputed:http://www.finnschmidt.nl/gen_xml2.php?regio=aare
> It is read in the following
> map:http://www.finnschmidt.nl/reis/aare/map/index2.php
>
> I want also use polyline between several markers. Markers with Type="X"
> should display a line beteween the markers.
> (http://econym.org.uk/gmap/example_map7.htm/
> http://econym.org.uk/gmap/example4.xml)
>
> The php file needs to do this, I have little programming scills, but so far
> it was working.
>
> Could some point me in the right direction, or give me some hints.
>
> If you need more info, please let me know.
>
> Guido
>
> <?php
> require("connect.php");
>
> // Get parameters from URL
> $regio = $_GET["regio"];
>
> // Start XML file, create parent node
> $dom = new DOMDocument("1.0");
> $node = $dom->createElement("markers");
> $parnode = $dom->appendChild($node);
>
> // Opens a connection to a mySQL server
> $connection=mysql_connect (localhost, $username, $password);
> if (!$connection) {
> die("Not connected : " . mysql_error());
>
> }
>
> // Set the active mySQL database
> $db_selected = mysql_select_db($database, $connection);
> if (!$db_selected) {
> die ("Can\'t use db : " . mysql_error());
>
> }
>
> // Search the rows in the markers table
> $query = sprintf("SELECT id, naam, lat, lng, info, url, type FROM markers
> WHERE `regio` = '$regio' ",
> mysql_real_escape_string($center_lat),
> mysql_real_escape_string($center_lng),
> mysql_real_escape_string($center_lat),
> mysql_real_escape_string($radius));
> $result = mysql_query($query);
>
> $result = mysql_query($query);
> if (!$result) {
> die("Invalid query: " . mysql_error());
>
> }
>
> header("Content-type: text/xml");
>
> // Iterate through the rows, adding XML nodes for each
> while ($row = @mysql_fetch_assoc($result)){
> $node = $dom->createElement("marker");
> $newnode = $parnode->appendChild($node);
> $newnode->setAttribute("naam", $row['naam']);
> $newnode->setAttribute("id", $row['id']);
> $newnode->setAttribute("info", $row['info']);
> $newnode->setAttribute("url", $row['url']);
> $newnode->setAttribute("type", $row['type']);
> $newnode->setAttribute("lat", $row['lat']);
> $newnode->setAttribute("lng", $row['lng']);
>
> }
>
> echo $dom->saveXML();
> ?>
--
You received this message because you are subscribed to the Google Groups
"Google Maps API V2" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api?hl=en.