hi everyone hope some one may be able to help me here,I have two points on a map I am trying to draw a line between the two points.
The data for the log and lat comes from a txt file that has been searched based upon mysql database results.
a working example of the script so far click here to view
I have obviously used code availble via google but I have tried for some time to get this line to appear I just can't seem to see whats wrong or whats missing.
also would that display new lines for each result gathered from the mysql db.
thanks for looking.
<script src="http://maps.google.com/maps?file=api&v=1&key=ABQIAAAAl4rudPIvt1r9YSx1RT2Y2RQldXIiksCayQDhY2g_-KxXyM6GoBQmRrq3xmyrCvUc8SZfgxoJft8LZw" type="text/javascript"></script>
<div id="map" style="width: 800px; height: 600px"></div>
<script type="text/javascript">
//<![CDATA[
var baseIcon = new GIcon();
baseIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_blue.png";
baseIcon.iconSize = new GSize(12, 20);
baseIcon.shadowSize = new GSize(13, 21);
baseIcon.iconAnchor = new GPoint(6, 20);
baseIcon.infoWindowAnchor = new GPoint(5, 1);
baseIcon.infoShadowAnchor = new GPoint(5, 1);
// Creates a marker whose info window displays the given number
function createMarker(point, text, markerstyle)
{
var icon = new GIcon(baseIcon);
icon.image = "http://labs.google.com/ridefinder/images/"+markerstyle+".png";
var marker = new GMarker(point, icon);
// Show this markers index in the info window when it is clicked
var html = text;
GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
return marker;
};
var map = new GMap(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.centerAndZoom(new GPoint(0, 0), 14);
<?php
$link = mysql_connect("localhost", "xxx", "xxx") or die("Could not connect: " . mysql_error());
mysql_select_db("xxxx",$link) or die ("Can\'t use dbmapserver : " . mysql_error());
$result = mysql_query("SELECT * FROM allflights WHERE pilot_id='UKV1248'LIMIT 1 ",$link);
if (!$result)
{
echo "green resultaten";
}
while($row = mysql_fetch_array($result))
{
$html1 = join ("",file('http://www.flyukva.com/flyuk/content/crewcentre/flightoperations/Airports.txt'));
preg_match_all("/($row[departure])(.*)/i", $html1, $takeoff);
//place all arrays in array and explode the info for retrieval for ten flights on ivao
$takeoff=array(explode(':', $takeoff[0][0], -1));
$metar=array(1 => "{$takeoff[0][1]}",2 => "{$takeoff[0][3]}",3 => "{$takeoff[0][0]}");
//echo '<b><pre>', print_r($takeoff, TRUE), '</b></pre>';
if ($metar{"1"}=='')
{$metar {"2"}='37.1219'; $metar{"1"}='107.5215';$metaricon='icon2';
}else{$metaricon='icon3';}
$html1 = join ("",file('http://www.flyukva.com/flyuk/content/crewcentre/flightoperations/Airports.txt'));
preg_match_all("/($row[destination])(.*)/i", $html1, $takeoff1);
//place all arrays in array and explode the info for retrieval for ten flights on ivao
$takeoff1=array(explode(':', $takeoff1[0][0], -1));
$metar1=array(1 => "{$takeoff1[0][1]}",2 => "{$takeoff1[0][3]}",3 => "{$takeoff1[0][0]}");
//echo '<b><pre>', print_r($takeoff, TRUE), '</b></pre>';
if ($metar1{"1"}=='')
{$metar1 {"2"}='37.1219'; $metar1{"1"}='107.5215';$metaricon1='icon2';
}else{$metaricon1='icon3';}
if ($row['online'] == 'Offline') $marker_type = 'mm_20_red';
if ($row['online'] == 'Online') $marker_type = 'mm_20_green';
$info_text = "<div id=\"infowindow\" style=\"white-space: nowrap;\"><b>" . $marker_type . "</b><br>" . $row['desc'] . "<br><br><a href=" . $row[online] . " target=_blank>Link</a></div>";
echo "var point = new GPoint(" . $metar{2} . "," . $metar{1}. ");\n";
echo "var marker = createMarker(point, 'Flight# " .$metar{3}." " . $row['flightno'] ."<br>Departing : " . $row['departure'] ."<br>Arriving : " . $row['destination'] . "<br> Aircraft : " . $row['aircraft'] . " <br>Take off" . $row['tbo'] . "<br>'
,'" .$marker_type . "');\n";
echo "map.addOverlay(marker);\n";
echo "\n";
$info_text = "<div id=\"infowindow\" style=\"white-space: nowrap;\"><b>" . $marker_type . "</b><br>" . $row['desc'] . "<br><br><a href=" . $row[online] . " target=_blank>Link</a></div>";
echo "var point = new GPoint(" . $metar1{2} . "," . $metar1{1}. ");\n";
echo "var marker = createMarker(point, 'Flight# " .$metar1{3}." ". $row['flightno'] ."<br>Departing : ". $row['departure'] ."<br>Arriving : " . $row['destination'] . "<br> Aircraft : " . $row['aircraft'] . " <br>Take off" . $row['tbo'] . "<br>'
,'" .$marker_type . "');\n";
echo "map.addOverlay(marker);\n";
echo "\n";
/*----------------------------code i think is the problem -----------------------------*/
echo "var polyline = new GPolyline([";
echo "new GPoint(". $metar{2} .",". $metar{1} .")";
echo ",\n";
echo "new GPoint(". $metar1{2} .",". $metar1{1} .")";
echo "],\"#ff0000\",5,9);\n";
echo "map.addOverlay(polyline);\n\n";[/COLOR]
/*____________________________________________________________*/
}
mysql_close($link);
?>
//]]>
</script>
</body>
</html>
<?echo '<b><pre>', print_r($takeoff, TRUE), '</b></pre><br>';?>
<?echo '<b><pre>', print_r($takeoff1, TRUE), '</b></pre>';?>