我有多個緯度。在谷歌地圖上繪製多個緯度和經度
var latlngs = [
{lat:25.774252,lng:-80.190262},
{lat:18.466465,lng:-66.118292},
{lat:32.321384,lng:-64.757370},
{lat:25.774252,lng:-80.190262},
];
實際上,它是從數據庫中使用Ajax響應檢索:
$.ajax({
url: "getLatlng.php",
type: 'post',
dataType: 'json',
success: function(response) {
for (i = 0; i < response.length; i++) {
// what should be the code here for plotting them on google maps
}
},
error: function(xhr){
console.log(xhr);
}
});
我希望他們在谷歌地圖繪製,每次我改變從數據庫的經緯度之一,標誌也應通過使用setInterval更改而不重新加載頁面。這實際上是用於GPS追蹤。我需要幫助。 任何幫助表示讚賞。
每次從服務器獲取新信息時,您只需設置標記爲null .setM ap(null)',然後在地圖上再次設置'.setMap()'。如何做到這一點在這裏被描述爲超過100倍,而谷歌文檔對於這一點非常清楚並且很好。 –
我建議查看[Documentation](https://developers.google.com/maps/documentation/javascript/markers)。你需要做的是清除地圖上的所有標記,然後每次再添加一次。 – George
你可以有一個在谷歌地圖上繪製多個latlng的示例嗎? – JSmith