i have text file called cordi.txt.Values of text file are as follows.
7.25177,80.59304 //line 1
7.25174,80.59383 //line 2
7.25177,80.59304 //line 3
7.25573,80.59635 //line 4
7.25573,80.59635 //line 5
7.25582,80.59500 //line 6
7.25582,80.59500 //line 7
7.25654,80.59497 //line 8
Using above GPS coordinates(reading from the cordi.txt file) i wanna overlay the google map using polylines function.I want to draw first polyline using coordinates in line 1 and 2 respectively.Second polyline should use coordinate in line 2 and 3.fourth should use coordinates in line 3 and 4.Like wise i wanna draw continues polylines from initial coordinate to last coordinte..
This is my code
Code: Select all
<?php
$myfile="cordi.txt";
$handle = fopen($myfile, 'r');
$numpoints=8 ;
$i=0;
$j=0;
$data = array( );
while ($i < $numpoints ) {
$data = fgets($handle);
$i=$i+1;
}
while ($j < $numpoints ) {
echo "
var polyline = new GPolyline([
new GLatLng($data[$j]),
new GLatLng($data[$j+1]),
],'#00ff00', 5, 1);
map.addOverlay(polyline);";
$j=$j+1;
}
//]]>
fclose($handle);
?>it will generate error.the error is as follows.
Parse error: parse error, expecting `']'' in C:\wamp\www\project\drawlinesfromtxttest.php on line 67
in my code in line 67, the piece of code is as follows.
Code: Select all
new GLatLng($data[$i+1]),