您可以從谷歌地圖退出經度和緯度。
例如,地址是「123街,洛杉磯,CA 12345」或地址郵政編碼只有「12346」
public void GetCoordinate(string address)
{
WebClient client = new WebClient();
Uri uri = new Uri(String.Format("http://maps.google.com/maps/geo?output=csv&q=" + HttpUtility.UrlEncode(address)));
// Return numbers -
// 1 = Status Code
// 2 = Accurancy
// 3 = Latitude
// 4 = Longitude
string[] geocodeInfo = client.DownloadString(uri).Split(',');
decimal latitude = Convert.ToDecimal(geocodeInfo[2]);
decimal longitude = Convert.ToDecimal(geocodeInfo[3]);
}
我建議保存UTC創建/更新的時間。在顯示它時,根據用戶的時區偏移量(保存在用戶的配置文件中)將該UTC轉換爲用戶的本地時間。
來源
2012-01-12 21:08:47
Win
你應該看看GeoIP--它使用IP地址來確定計算機的地理位置。 – 2012-01-12 21:00:26
就像我說的,用戶將基於東海岸,所以電腦的時間是EST。這不是我需要的。 – jmease 2012-01-12 21:11:13