【问题标题】:Multiple marker with latlngs value from database来自数据库的具有 latlngs 值的多个标记
【发布时间】: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"}]

【问题讨论】:

  • 能否详细说明您的问题
  • @Nitesh 基本上我想将我的 php 的输出作为 var 位置中的值调用到我的 html 中
  • @AlNoman 好的,感谢您的评论!我会看看并更新你的结果:)
  • @AlNoman 我的输出类似于 ["Tampines Street 86, Singapore",1.3497658,103.9274115]。现在如何在我的 html 中将其称为位置值?

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


【解决方案1】:

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

【讨论】:

  • 我似乎无法让它工作。它也需要在一个循环中
猜你喜欢
  • 2011-06-23
  • 1970-01-01
  • 2018-10-04
  • 2016-05-26
  • 1970-01-01
  • 2018-02-14
  • 1970-01-01
  • 2011-10-05
  • 1970-01-01
相关资源
最近更新 更多