Googleマップで計算された2つの住所の距離はありますか? どのようにですか?住所間の距離
住所間の距離
答えて
あなたはGoogle Directions APIを使用してこれを行うことができます
(あなたがルートの距離を必要とするとき)、あなたはアドレス文字列として、またはAPIの開始/終了位置を通過しDistance Matrix serviceまたはDirections-Serviceにリクエストを送ります座標とGoogleはあなたのためにすべての足の仕事を行います。
ルートは、指定したウェイポイント数に基づいてさまざまなものから構成されています(legs)。あなたのシナリオ(0ウェイポイント)には、推定される距離プロパティを持つ1つのレッグしか持たないようにしてください。
2つのアドレスがある場合は、最初にGEOCODINGで緯度経度を取得してから、距離を取得する方法が多数あります。
OR
あなたがジオコーディングを必要といけないし、CS SOLUTIONをしたい場合は、この試してください:あなたがGoogleや必要性を台無しにしたいいけない場合
public int getDistance(string origin, string destination)
{
System.Threading.Thread.Sleep(1000);
int distance = 0;
//string from = origin.Text;
//string to = destination.Text;
string url = "http://maps.googleapis.com/maps/api/directions/json?origin=" + origin + "&destination=" + destination + "&sensor=false";
string requesturl = url;
//string requesturl = @"http://maps.googleapis.com/maps/api/directions/json?origin=" + from + "&alternatives=false&units=imperial&destination=" + to + "&sensor=false";
string content = fileGetContents(requesturl);
JObject o = JObject.Parse(content);
try
{
distance = (int)o.SelectToken("routes[0].legs[0].distance.value");
return distance;
}
catch
{
return distance;
}
return distance;
//ResultingDistance.Text = distance;
}
protected string fileGetContents(string fileName)
{
string sContents = string.Empty;
string me = string.Empty;
try
{
if (fileName.ToLower().IndexOf("http:") > -1)
{
System.Net.WebClient wc = new System.Net.WebClient();
byte[] response = wc.DownloadData(fileName);
sContents = System.Text.Encoding.ASCII.GetString(response);
}
else
{
System.IO.StreamReader sr = new System.IO.StreamReader(fileName);
sContents = sr.ReadToEnd();
sr.Close();
}
}
catch { sContents = "unable to connect to server "; }
return sContents;
}
OR
をAIR DISTANCE、試してみてください:
public decimal calcDistance(decimal latA, decimal longA, decimal latB, decimal longB)
{
double theDistance = (Math.Sin(DegreesToRadians(latA)) *
Math.Sin(DegreesToRadians(latB)) +
Math.Cos(DegreesToRadians(latA)) *
Math.Cos(DegreesToRadians(latB)) *
Math.Cos(DegreesToRadians(longA - longB)));
return Convert.ToDecimal((RadiansToDegrees(Math.Acos(theDistance)))) * 69.09M * 1.6093M;
}
JObjectパーサーはどこで入手できますか – user1901860
そして、fileGetContentsの機能は何ですか? – user1901860
JSon linqをダウンロードしました: http://james.newtonking.com/pages/json-net.aspx – user1901860
これを行いましたが、空の文字列が返されます。 url = "http://maps.googleapis.com/maps/api/directions/json?origin=3320、rue de verdun、verdun &目的地= 379、19e道、La Guadeloupe、G0M 1G0 & sensor = false"
public string fileGetContents(string url)
{
string text = "";
var webRequest = HttpWebRequest.Create(url);
IAsyncResult asyncResult = null;
asyncResult = webRequest.BeginGetResponse(
state =>
{
var response = webRequest.EndGetResponse(asyncResult);
using (var sr = new StreamReader(response.GetResponseStream()))
{
text = sr.ReadToEnd();
}
}, null
);
return text;
}
- 1. Googleマップを使用しない住所間の距離を計算する
- 2. mysqlの間の距離
- 3. SQL関数と距離の間の距離が最も近い
- 4. 場所間の距離を見つける方法
- 5. 2か所の物理的距離
- 6. 2つのポイント間の距離と距離が最も離れています
- 7. 2つの場所の間の運転距離と移動時間
- 8. GoogleアドレスAPI URL住所住所の例
- 9. 計算フュージョンテーブルのポイント間の距離
- 10. ヘッダーとページリストの間の距離ブロガー
- 11. 2つのdiv間の垂直距離
- 12. 2つのポストコード間の距離
- 13. リストビュー内のアイテム間の距離
- 14. 座標間の距離のBinarySearch
- 15. ファクトAPIとGoogle Places APIの距離マトリックス(距離と時間)について
- 16. 単語間の詳細な距離
- 17. 2点間の距離と角度
- 18. numpy配列間の距離、列方向
- 19. ドロップダウンリストと要素間の距離
- 20. ボックス間の距離を決定する
- 21. 2点間の測地線距離
- 22. 時間、距離、スピードの使い方は?
- 23. iphoneの2つの場所の間の距離を取得する
- 24. 2つの場所の間のルートと距離を示すGoogleマップ
- 25. 道路に基づく2つの場所間の距離を計算する
- 26. ジオコーディングを使用して2つの場所間の距離を取得する
- 27. 住所のカスタムシート
- 28. 距離のクエリ
- 29. 現在の場所と指定された場所の間の道路の距離を見つける
- 30. 住所:&(数)
ようこそStackOverflow!あらゆる種類の助けを提供するためには、より詳細な情報を提供する必要があります。どのような種類のデータを扱っていますか?何を試してみましたか(具体的にどのようなコードを書いていますか?) –