0
有沒有從Google地圖獲取座標的正確方法?從MySQL數據庫的谷歌地圖座標,正確的方法來優化?
我現在的做法是我有jQuery腳本從一個填充元素獲取座標,我使用MySQL填充座標列表。
// jQuery script to get the coordinates
var coordArray = [];
$(".marker").each(function(index,div)
{
var coords = $(this).data("coords").split(",");
coordArray.push([coords[0],coords[1]]);
});
//while loop in PHP and I have displayed the coordinates within a <div> element:
while($row = $sql->fetch(PDO::FETCH_ASSOC))
{
<div class="marker" data-coords="<?php echo $row['lat'].",".$row['lng'];?>">stuff</div>
}
有沒有更好的方法呢?或者這也可以嗎?
使用JSON ..更有效率 – charlietfl
@charlietfl你介意給我一個例子,我會怎麼做?或者如果有一個如何做的例子? – hellomello