I'm trying to show in google maps api v3 polylines that are stored in my database
Here is the connection to 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 in 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 looks like this:
[{"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 do not know how to enter this data in the varial (example):
var flightPlanCoordinates =[
{lat:16.88746121, lng:-24.98925626},
{lat:16.8883595, lng:-24.98959154},]
I know I need to loop but I do not know how. I've seen similar post but could not do it, any help please.