简体   繁体   中英

Convert Google Maps Locations that are displaying to XML Format as Output (ASP.Net, C#)

I am doing a web application in Asp.Net, to retrieve Near By Places.

For getting this, i am using the below link,

https://maps.google.com/?q=area&near=ameerpet&radius=1

From the above link i am getting the places with in 5 kms having the output in the form of displaying locations in Google Maps.

But i want to give the above link as input and i need to get my output as in the form of XML format by using C# Coding or Javascript in ASP.Net.

Ex:

   <Area>

    Keshavanagar Colony, Srinagar Colony Rd, Yousufguda, AP, India ‎

   </Area>

   <Area>       

   MCH Park Area, Padala Ramareddy Colony, Yousufguda, Hyderabad, AP, India 
   </Area>

   <Area>

   Athithi Inn, Dharam Karan Rd, Divyashakti Appartments, Ameerpet, Hyderabad, AP 500016, India

   </Area>

   <Area>

   GreenPark-Hyderabad, 7-1-26, Ameerpet Road,Begumpet,Hyderabad, Andhra Pradesh 500016, India ‎

and soon......

Can any one please help me how to convert google maps to XML format by using C# Coding or Javascript in ASP.Net.

Thanks in Advance


upon searching in many forums i got the below link;

https://maps.google.com/?q=area&output=json&near=ameerpet&radius=1

By using this link i am getting my output as JSON file.

But i don't want to download that file. Just i want to make a call to that link from my C# Code and i need to seperate my address block from that and i need to display that in my ASP Listbox or grid View Control.

By using that link i have tried converting JSON data to string or an array variable with C# code. My Code is like as,

var address = String.Format(" https://maps.google.com/?q=area&output=json&near=ameerpet&radius=1 ");

var result = new System.Net.WebClient().DownloadString(address);

JavaScriptSerializer jss = new JavaScriptSerializer();

Object a = jss.DeserializeObject(result);

I am getting my result JSON data in "result" variable. But at the time of deserialization, i am getting an error.

I was struct at this area.

Can any one please help me by providing code to convert a JSON data to a string or an array format using C# Coding. As i need to display that data in ASP Listbox.

Thanks in Advance.

For that purpose you should use Google Geocoding API . There you can specify response type (JSON or XML) and convert it to your desired XML format.

I think you should use GoogleMaps API, just one similar example:

string json = GetRequest.GetInstance(String.Format(
                    "http://maps.google.com/maps/geo?q={0}&output=json", address)).DoRequest(String.Empty);

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                dynamic o = serializer.DeserializeObject(json);

                object[] coordinates = o["Placemark"][0]["Point"]["coordinates"];

                return new Position()
                {
                    Latitude = Convert.ToDouble(coordinates[0]),
                    Longitude = Convert.ToDouble(coordinates[1])
                };

You can specify 'output' to be XML format.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM