我在桌子上有拉特和lng。
如何从lat和lng获取地址?我试过这个:
using Artem.Google.Net;
SqlConnection con =
new SqlConnection("Data Source=local;Initial Catalog=DB;User ID=sa;Password=");
con.Open();
var com = new SqlCommand("SELECT * FROM Trucks WHERE plate=@id", con);
com.Parameters.AddWithValue("id", truckPlate.Trim());
var da = new SqlDataAdapter(com);
System.Data.DataTable dt = new System.Data.DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
labelLat.Text = dt.Rows[0][4].ToString();
labelLat.DataBind();
labelLng.Text = dt.Rows[0][5].ToString();
labelLng.DataBind();
double lat = Convert.ToDouble(labelLat.Text);
double lng = Convert.ToDouble(labelLng.Text);
GeoRequest request = new GeoRequest(lat, lng);
GeoResponse response = request.GetResponse();
string address = response.Results[0].FormattedAddress;
lblAddress.Text = address.ToString();
}
else
{
labelNote.Text="Truck is offline";
}
错误:
System.ArgumentException: Requested 'bus_station' value is not found
在这一行
GeoResponse response = request.GetResponse();
我在SQL或Aspx代码中没有“bus_station”。这是什么?