Kemal Ekren Kemal Ekren - 27 days ago 17
ASP.NET (C#) Question

Get City Name from Reverse Geocoding with latitude and longitude

http://maps.googleapis.com/maps/api/geocode/xml?latlng=39.952853,32.901470&sensor=false

In this xml url, I couldn't get data from area which is explained in the below.

<long_name>Altınevler Mahallesi</long_name>


I'm using asp.net c#. Could you help me with this?

This is the code I tried to get the data from xml

XmlDocument xdoc = new XmlDocument();
xdoc.Load(
"http://maps.googleapis.com/maps/api/geocode/xml?latlng=39.952853,32.901470&sensor=false"
);

XmlNodeList xNodelst = xdoc.DocumentElement.SelectNodes("entry");

foreach (XmlNode xNode in xNodelst)
{
label1.Text += "read";
}

Answer

I solved my question if anyone wants know be my guess. Solution indicated in the below.

Thank you

XmlDocument xDoc = new XmlDocument();
        xDoc.Load("https://maps.googleapis.com/maps/api/geocode/xml?latlng=" +coordinate+"&location_type=ROOFTOP&result_type=street_address&key=YOURAPIKEY");

        XmlNodeList xNodelst = xDoc.GetElementsByTagName("result");
        XmlNode xNode = xNodelst.Item(0);
        string adress = xNode.SelectSingleNode("formatted_address").InnerText;
        string mahalle = xNode.SelectSingleNode("address_component[3]/long_name").InnerText;
        string ilce = xNode.SelectSingleNode("address_component[4]/long_name").InnerText;
        string il = xNode.SelectSingleNode("address_component[5]/long_name").InnerText;

so you can pull anydata for google maps.