sasa lazic

sasa lazic

  • NA
  • 104
  • 49.9k

get altitude(elevation) from map provider

Dec 14 2013 2:25 AM
Ok whats the problem ?

I want to get elevation with Google maps.
I made code

List<double> visineRuteSaGoogla = new List<double>();
            int koliko = koordinateRuteLat.Count();
            WebResponse response = null;
            StreamReader reader = null;
            string result = null;

                for (int i = 0; i < koliko; i++)
                {
                    string url = CreateRequest("" + koordinateRuteLat[i] + "," + koordinateRuteLng[i]);
                    try
                    {
                        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                        request.Method = "GET";
                        response = request.GetResponse();
                        reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
                        result = reader.ReadToEnd();
                        dynamic m = JsonConvert.DeserializeObject<object>(result);
                        dynamic elev = m.results[0];
                        double visinaRutaTacke = elev.elevation;
                        visineRuteSaGoogla.Add(visinaRutaTacke);
                    }
                    catch (Exception ex)
                    {
                        // handle error
                        MessageBox.Show(ex.Message);
                    }

What is the problem

I keep getting a result out of range

If the query is 50 elevation, no problem
how to make multiple queries of 50
I have no idea