具有来自数据库的latlngs值的多个标记

时间:2016-12-07 10:26:12

标签: php google-maps google-maps-markers

我需要将latlngs值输入locations之类的内容:

var locations = [
['Bondi Beach', -33.890542, 151.274856],
['Coogee Beach', -33.923036, 151.259052],
['Cronulla Beach', -34.028249, 151.157507]       
['Manly Beach', -33.80010128657071, 151.28747820854187],
['Maroubra Beach', -33.950198, 151.259302]
];

这是我的PHP代码:

$result = $conn->query("select address, lat, lang from user where phoneno = '" . $phoneno. "'");

$outp = "[";
while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
if ($outp != "[") {$outp .= ",";}
$outp .= '{"address":'  . $rs["address"] . ',';
$outp .= '"lat":"' . $rs["lat"] . '",';
$outp .= '"lang":"'   . $rs["lang"]        . '"}';
}
$outp .="]";

这是url中的值输出:

[{"address":Tampines Street 86,
  Singapore,"lat":"1.3498584","lang":"103.9273744"}]

1 个答案:

答案 0 :(得分:0)

您需要从php中获取这些值并在HTML中填充。 Here is an sample.