private void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)// ********* { var rootObject = JsonConvert.DeserializeObject <RootObject>(e.Result); int x = 0; foreach (var book in rootObject.sfx_web_service) { foreach (var item in book.maps) { MapIcon mpi = new MapIcon(); /*System.Diagnostics.Debug.WriteLine(item.place + " id "); * System.Diagnostics.Debug.WriteLine("-103." + item.longitude + " nombre "); * System.Diagnostics.Debug.WriteLine("20." + item.latitude + " imagen ");*/ if (x <= 4) { mpi.longitud = iteso[x, 1].ToString(); mpi.latitud = iteso[x, 0].ToString(); x++; } else if (x == 5) { break; } else { mpi.longitud = "-103." + item.longitude; mpi.latitud = "20." + item.latitude; } Location offset = new Location() { Latitude = Convert.ToDouble(mpi.latitud), Longitude = Convert.ToDouble(mpi.longitud), //Latitude = 20.609597, //Longitude = -103.412007, //Latitude = 20.725220,//zoo //Longitude = -103.307884, //zoo //Latitude = iteso[x,0], //Longitude = iteso[x,1], Altitude = Double.NaN // NaN will keep it on the horizon }; System.Diagnostics.Debug.WriteLine(offset.Latitude + " nombre "); System.Diagnostics.Debug.WriteLine(offset.Longitude + " imagen "); dest = new GeoCoordinate(offset.Latitude, offset.Longitude); me = MyMap.Center; Double distance = me.GetDistanceTo(dest); distance = Math.Round(distance, 0); mpi.lugar = item.place + " " + distance.ToString() + " m"; System.Diagnostics.Debug.WriteLine(distance + " distancia"); AddLabel(offset, item.place + " " + distance.ToString() + " m"); listPushpin.Add(mpi); } } drawPushpin(listPushpin); }
public void cargarLista() //lee las coordenadas del archivo xml { StringBuilder output = new StringBuilder(); XElement booksFromFile = XElement.Load(@"Resources/coordenadas.xml"); String xmlString = booksFromFile.ToString(); using (XmlReader reader = XmlReader.Create(new StringReader(xmlString))) { int i = 0; while (i < 112) { MapIcon imp = new MapIcon(); reader.ReadToFollowing("id"); reader.MoveToFirstAttribute(); output.AppendLine(reader.ReadElementContentAsString()); imp.id = output.ToString(); imp.id = imp.id.Substring(0, imp.id.Length - 2); output.Clear(); reader.ReadToFollowing("Latitude"); reader.MoveToFirstAttribute(); output.AppendLine(reader.ReadElementContentAsString()); imp.latitud = "20." + output.ToString(); //imp.latitud = imp.latitud.Substring(0, imp.latitud.Length -2); output.Clear(); reader.ReadToFollowing("Longitude"); reader.MoveToFirstAttribute(); output.AppendLine(reader.ReadElementContentAsString()); imp.longitud = "-103." + output.ToString(); //imp.longitud = imp.latitud.Substring(0, imp.latitud.Length -2); output.Clear(); reader.ReadToFollowing("Place"); reader.MoveToFirstAttribute(); output.AppendLine(reader.ReadElementContentAsString()); imp.lugar = output.ToString(); //imp.longitud = imp.latitud.Substring(0, imp.latitud.Length -2); output.Clear(); listPushpin.Add(imp); i++; } } drawPushpin(listPushpin); }