我在Google地图中使用DataTable。我从服务器端json获得经度和纬度。这里我改变了地址,并将该地址分配给DataTable数据(TD)。坚持它会给出错误。
var geocoder;
geocoder = new google.maps.Geocoder();
var DataTable = $('#DataTable').dataTable({
"sAjaxSource": "php/totalDevices.php",
"aoColumns": [{
"mData": "name",
"sTitle": "User Name"
}, {
"mData": "managerName"
}, {
"mData": "imei"
}, {
"mData": "email"
}, {
"mDataProp": null,
"mData": null,
"fnRender":function ( obj ) {
var latlng = new google.maps.LatLng(obj.aData['latitude'], obj.aData['longitude']);
geocoder.geocode({
'latLng': latlng
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
var address = results[0].formatted_address;
console.log(address);
return address;
//callback(address);
} else {
alert('No results found');
}
} else {
alert('Geocoder failed due to: ' + status);
}
});
//return getAddress(obj.aData['latitude'],obj.aData['longitude']);
},
}],
});