1
I am trying to show in google maps api v3 polylines that are stored in my database
Here is the connection with the conf.inc.php database :
<?php
define('HOST','localhost');
define('USER','xxxx');
define('PASS','xxxxx');
define('DBSA','polilinha');
define('TABLE','marcador');
$link= mysqli_connect(HOST,USER,PASS,DBSA) OR die('ERROR!');
?>
I get the data from my database this way:
<?php require '_app/conf.inc.php';
//fazendo a consulta na base de dados`
$Qrcreate = "SELECT * FROM " . TABLE. "";
$create = mysqli_query($link,$Qrcreate);
while ($row = mysqli_fetch_assoc($create)) {
vector[] = $row;
}
echo json_encode($vector);
?>
My output appears this way:
[{"id":"1","lat":"16.8875","lng":"-24.9893"},{"id":"2","lat":"16.8884","lng":"-24.9896"},{"id":"3","lat":"16.889","lng":"-24.9903"},{"id":"4","lat":"16.8891","lng":"-24.9911"}]
My problem is that I don’t know how to enter this data into the variable (example):
var flightPlanCoordinates =[
{lat:16.88746121, lng:-24.98925626},
{lat:16.8883595, lng:-24.98959154},]
I know I need to loop, but I don’t know how. I have seen similar post but could not do, any help please .
http://meta.pt.stackoverflow.com/questions/5389 ;-)
– bfavaretto
Hello, welcome to the site. If any of the answers below solved your problem, you can mark her as accepted. Here we do not put "SOLVED" in the title (see the link above).
– bfavaretto