|
Posted by phill.luckhurst@googlemail.com on 06/16/07 17:15
I've now got a form that will output to a MySql database as you can
see here.
http://www.windsurf.me.uk/form166/form.html
Obviously the graphical look needs work.
I am then using a little php to read those to create this
http://www.windsurf.me.uk/usermap.php
using this code
<code>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Who locations in London</title>
<script src="http://maps.google.com/maps?
file=api&v=2&key=ABQIAAAAXIIfOy9RqRn6Joxvjn0lIxR3sZnehZIYWrxGjIHvkcGdHqJv2B
QnhafXU6ucIsJNlj4yLfWXwdSoTQ"
type="text/javascript"></script>
</head>
<body>
<p><strong>Windsurfing Spots, Shops, Webcams and windsurfers</
strong></
p>
<div id="map" style="width: 500px; height: 400px"></div>
<script type="text/javascript">
//<![CDATA[
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.setCenter(new GLatLng(54.512161, -1.17523), 5, G_NORMAL_MAP);
// Creates a marker whose info window displays the given number
function createMarker(point, number)
{
var marker = new GMarker(point);
// Show this markers index in the info window when it is clicked
var html = number;
GEvent.addListener(marker, "click", function()
{marker.openInfoWindowHtml(html);});
return marker;
};
<?php
$link = mysql_connect("localhost", "[Username]", "[password]") or
die("Could not connect: " . mysql_error());
mysql_selectdb("[dbname]",$link) or die ("Can\'t use dbmapserver :
" .
mysql_error());
$result = mysql_query("SELECT * FROM locations",$link);
if (!$result)
{
echo "no results ";
}
while($row = mysql_fetch_array($result))
{
echo "var point = new GLatLng(" . $row['field_10'] . "," .
$row['field_9'] . ");\n";
echo "var marker = createMarker(point, '" .
addslashes($row['field_1']) . "<b>" . $row['field_2'] . " </b><b>" .
$row['field_3'] . " </b><p>" . $row['field_4'] . " </p><p>" .
$row['field_4'] . " </p><p>" . $row['field_6'] . " </p><p>" .
$row['field_7'] . " </p><p>" . $row['field_8'] . " </p><p>" .
$row['field_11'] . " </p><p>" . $row['field_12'] . " </p>');\n";
echo "map.addOverlay(marker);\n";
echo "\n";
}
mysql_close($link);
?>
//]]>
</script>
<body>
</body>
</html>
</code>
I'm just having a little trouble with the finishing touches.
The simple ones first.
1) What do I use instead of the <p> </p> tags to designate a new line
without a space?
2) I need this field . $row['field_11'] . to work as a link but I'm
not sure how to do it.
and now for the hard bit
3) Field 1 can be one of 5 items from a drop down. I would like the
map to have a different custom icon for each one of the selections.
I'm sure all this can be achieved but I'n very new to coding so am
struggling a bit.
Navigation:
[Reply to this message]
|