Hi all
I am using VB Express 2008.
Sorry for the rather long post but I felt it would explain my problem better.
I have used the code convertor at developerfusion to convert the following two pieces of code (originaly from http://www.justagile.com/blogs/posts...ogle-maps.aspx.
Can anyone tell me how to get the returned Latitude and Longitude values to display in my textboxes named tab5txtLatitude and tab5txtLongitude?
Original code part 1
Original code part 2Code:public static GeocoderLocation Locate(string query) { WebRequest request = WebRequest.Create("http://maps.google.com/maps?output=kml&q=" + HttpUtility.UrlEncode(query)); using (WebResponse response = request.GetResponse()) { using (Stream stream = response.GetResponseStream()) { XDocument document = XDocument.Load(new StreamReader(stream)); XNamespace ns = "http://earth.google.com/kml/2.0"; XElement longitudeElement = document.Descendants(ns + "longitude").FirstOrDefault(); XElement latitudeElement = document.Descendants(ns + "latitude").FirstOrDefault(); if (longitudeElement != null && latitudeElement != null) { return new GeocoderLocation { Longitude = Double.Parse(longitudeElement.Value, CultureInfo.InvariantCulture), Latitude = Double.Parse(latitudeElement.Value, CultureInfo.InvariantCulture) }; } } } return null; }
Converted code part 1Code:[Serializable] public class GeocoderLocation { public double Longitude { get; set; } public double Latitude { get; set; } public override string ToString() { return String.Format("{0}, {1}", Latitude, Longitude); } }
Converted code part 2Code:Public Shared Function Locate(ByVal query As String) As GeocoderLocation Dim request As WebRequest = WebRequest.Create("http://maps.google.com/maps?output=kml&q=" & HttpUtility.UrlEncode(query)) Using response As WebResponse = request.GetResponse() Using stream As Stream = response.GetResponseStream() Dim document As XDocument = XDocument.Load(New StreamReader(stream)) Dim ns As XNamespace = "http://earth.google.com/kml/2.0" Dim longitudeElement As XElement = document.Descendants(ns + "longitude").FirstOrDefault() Dim latitudeElement As XElement = document.Descendants(ns + "latitude").FirstOrDefault() If longitudeElement IsNot Nothing AndAlso latitudeElement IsNot Nothing Then Return New GeocoderLocation() End If End Using End Using Return Nothing End Function
Conversion seems to have been done ok apart from the two lines (in red text) which appear to be missing from the converted function.Code:<Serializable()> _ Public Class GeocoderLocation Private _Longitude As Double Public Property Longitude() As Double Get Return _Longitude End Get Set(ByVal value As Double) _Longitude = value End Set End Property Private _Latitude As Double Public Property Latitude() As Double Get Return _Latitude End Get Set(ByVal value As Double) _Latitude = value End Set End Property Public Overloads Overrides Function ToString() As String Return [String].Format("{0}, {1}", Latitude, Longitude) End Function End Class
I call the locate function using
Thanks in advance for any help.Code:Locate(tab5txtPostCode.text)





Reply With Quote