【发布时间】:2017-04-22 05:58:09
【问题描述】:
我需要将我的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"}]
【问题讨论】:
-
能否详细说明您的问题
-
看看@json_encode php.net/manual/en/function.json-encode.php
-
@Nitesh 基本上我想将我的 php 的输出作为 var 位置中的值调用到我的 html 中
-
@AlNoman 好的,感谢您的评论!我会看看并更新你的结果:)
-
@AlNoman 我的输出类似于 ["Tampines Street 86, Singapore",1.3497658,103.9274115]。现在如何在我的 html 中将其称为位置值?
标签: php google-maps google-maps-markers