Select to view content in your preferred language

Get Location using Reverse Geocoding in Win CE device takes too much time why?

523
0
04-05-2013 10:11 PM
HarishM
New Contributor
Hi everyone,
                I am developing a Windows application for Win CE hand-held device(C5000w), a Chinese product.

Check this site:
                 http://www.chainway.net/products/C5000W.asp

for further details of the device.

I am using C# language to develop my application using Microsoft Visual Studio 2008.

Right now,I was trying to get the current location of my place by framing a request by passing the Latitude & Longitude as the
parameters(i.e.Reverse Geocoding).

Its taking too much time to get the response from the server and i don't know the exact reason why it is taking that much time.

This the code i have tried:


private void GetLocation(string Lattitue, string Longitude)
        {
            try
            {
         HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format("http://maps.googleapis.com/maps/api/geocode/json?latlng={0},{1}&sensor=true", Lattitue, Longitude));

               WebResponse response = request.GetResponse();

                StreamReader readStream = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
                string page = readStream.ReadToEnd();
                if (page.Contains("\"formatted_address"))
                {
                    int formatted_address_index = page.IndexOf("\"formatted_address");
                    int formatted_address_end_index = page.IndexOf("\",", formatted_address_index);
                    string res = page.Substring(formatted_address_index, (formatted_address_end_index - formatted_address_index) + 1);
                    string[] res1 = res.Split(':');
                    textBox3.Text = res1[1];
                }
                else
                {
                    textBox3.Text = "No information available";
                }
               

            }
            catch
            {
                throw;
               
            }
            finally
            {
                if (request != null)
                    request = null;

                if (response != null)
                    response.Close();
            }
        }



Does anyone know why it is taking too long to respond or whether i need to change my coding or might be problem with the device?

I googled and found out that this is the URL most people are suggesting to get the current location.

I was not able to get any solution.

Help me with this?????
Tags (2)
0 Kudos
0 Replies