【发布时间】:2024-05-20 17:45:02
【问题描述】:
我已经编写了获取标记的 JOSN 并遍历它们的部分。但由于某种原因,这些标记没有出现在地图上。有人可以帮我找出错误。
$.ajax({
url: "get_markers.php",
type: 'POST',
dataType: 'json',
data: {'address':address},
success: function (html, status, response) {
$.each(html, function(i, place) {
alert(JSON.stringify(place.lat)+","+JSON.stringify(place.lng));
latLng = new google.maps.LatLng(JSON.stringify(place.lat), JSON.stringify(place.lng));
marker = new google.maps.Marker({
position: latLng,
map: map
//title: data.title
});
});
}
我已经定义了地图变量,latLng 和 marker。当我执行警报(..)时,我也会得到正确的 lat 和 lang 值。
谢谢
【问题讨论】:
标签: javascript ajax json google-maps-api-3