Google Haritalar tarafından hesaplanan 2 adres arasında bir mesafe olması mümkün mü? Nasıl?Adresler arasındaki mesafe
cevap
Sen Google Directions API kullanarak yapabilirsiniz
(bir rotanın mesafeyi gerektiğinde), adres dizeleri ya da API başlangıç / bitiş yerleri geçmesi Distance Matrix service veya Directions-Service için bir istek gönderin Koordinatlar ve Google tüm bacağınızı sizin için yapacak.
Yollar, belirttiğiniz kaç yol noktasına bağlı olarak çeşitli 'dan oluşur. Senaryosunda (0 yol noktası), sadece tahmini bir mesafe özelliğine sahip olan 1 ayağa sahip olmalısınız.
Sadece iki eklentiniz varsa, ilk olarak GEOCODING numaralı telefonu kullanın ve sonra aralarında mesafe elde etmek için birçok yöntem var.
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;
}
VEYA
google ve ihtiyaç uğraşmak istemiyorsanız:
VEYA
Eğer coğrafi kodlama ihtiyacım yok ve eğer bir CS ÇÖZÜM Bu deneyin istiyorum sadece AIR DISTANCE, Bunu deneyin:
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 ayrıştırıcısını nereden bulabilirim – user1901860
Ve fileGetContents fonlaması nedir? – user1901860
JSon linq'i buradan indirdim: http://james.newtonking.com/pages/json-net.aspx – user1901860
Ve ben bunu yaptım: ancak boş bir dize döndürür. url = "http://maps.googleapis.com/maps/api/directions/json?origin=3320, rue de verdun, verdun & hedef = 379, 19e avenue, La Guadeloupe, G0M 1G0 & algılayıcı = 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. 2 postcodes arasındaki mesafe
- 2. Liste Görünümündeki öğeler arasındaki mesafe
- 3. ggplot boxplots arasındaki mesafe artışı
- 4. İki android telefon arasındaki mesafe
- 5. mesafe?
- 6. mesafe
- 7. Bir menüdeki elemanlar arasındaki eşdeğer mesafe css
- 8. İki konum arasındaki mesafe - Google Maps
- 9. Sözdizimsel benzerlik/mesafe nltk
- 10. Java'da mesafe formülünü kullanma
- 11. C++ cinsinden belirli türdeki işaretçiler arasındaki mesafe kısıtlaması nedir?
- 12. açılır liste ve neb üzerindeki öğe arasındaki mesafe
- 13. Coğrafi nokta ile belirli bir çokgen arasındaki mesafe nasıl hesaplanır?
- 14. 2 veya daha fazla Yüzen Eylem Düğmesi arasındaki mesafe nedir?
- 15. HAVERSINE mesafe
- 16. hakkında Mesafe API
- 17. Posta kodu mesafe hesap makinesi
- 18. Adresler, yeniden yazım ve çoklu kalıtım
- 19. Azure web siteleri için ayrılmış giden adresler
- 20. tarihinde Fit API Mesafe -
- 21. SWIFT Realm.io filtreye mesafe
- 22. mesafe matris içinde
- 23. SQL Server 2008 R2 Coğrafya Mesafe?
- 24. Mesafe Matrisine Dayalı Kümeleme Metodu
- 25. STL yineleyiciler std :: mesafe() hatası
- 26. SQL'de mesafe hesaplama nasıl geliştirilir
- 27. Üst janta kaydırılan mesafe algılaması
- 28. Android: liste görünümündeki pusula + mesafe
- 29. Google MAP API v3: computeDistanceBölüm metodu ve metrik formdaki mesafe
- 30. olsun noktası yön ve mesafe (vektör) ikinci noktanın koordinatlarını bulmalıyız
StackOverflow'a Hoş Geldiniz! Her türlü yardımı sağlayabilmemiz için çok daha fazla detay vermeniz gerekecek. Ne tür bir veri ile uğraşıyorsunuz? Ne denediniz (özellikle, ne tür bir kod yazdınız)? –