Google dan direction bilgisini liste çeklinde almak için başlangıç ve bitiş kordinatlarını vermeniz yeterlidir. Direction ı Adresten adrede şeklinde almak isterseniz Orgin ve Destination a kordinat yerine adres bilgisi göndermeniz yeterli olacaktır.
public List<DirectionRoute> direction(string lat1, string log1, string lat2, string log2) { XmlTextReader okuyucu = new XmlTextReader("http://maps.googleapis.com/maps/api/directions/xml?origin=" + lat1.Replace(',', '.') + "," + log1.Replace(',', '.') + "&destination=" + lat2.Replace(',', '.') + "," + log2.Replace(',', '.') + "&sensor=false"); XmlDocument dokuman = new XmlDocument(); dokuman.Load(okuyucu); XmlNodeList lat = dokuman.SelectNodes("/DirectionsResponse/route/leg/step/start_location/lat"); XmlNodeList log = dokuman.SelectNodes("/DirectionsResponse/route/leg/step/start_location/lng"); GooglePolyline NormalWay = new GooglePolyline(); NormalWay.Color = System.Drawing.Color.Black; NormalWay.Opacity = 1; List<DirectionRoute> routes = new List<DirectionRoute>(); for (int i = 0; i < lat.Count; i++) { routes.Add(new DirectionRoute { lat = Convert.ToDouble(lat.Item(i).InnerText.Replace('.', ',')), log = Convert.ToDouble(log.Item(i).InnerText.Replace('.', ',')) }); } return routes; } public class DirectionRoute { public double lat; public double log; }
Api ile birlikte farklı bilgilerde dönmektedir kordinat bilgisini aldığınız gibi diğer bilgileride alabilirsiniz.
Etiketler:adrede, adres, adresten, almak, api, baslang, bilgisi, bilgisini, bitis, ceklinde, dan, destination, direction, directions, gondermeniz, Google, için, isterseniz, kordinat, kordinatlar, liste, olacakt, orgin, seklinde, vermeniz, yerine, yeterli, yeterlidir, yol göster