Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I search near by palce using google api

https://maps.googleapis.com/maps/api/place/textsearch/xml?query=restaurants+in+Sydney&key=YOUR_API_KEY


I want only vicinity information from result in json format.

Please advise how can I filter result and display only vicinity(address) information in json format.



String sURL = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=";
sURL += objNearByServicesRequest.Latitude + "," + objNearByServicesRequest.Longitude;
sURL += "&radius=" + WebConfigurationManager.AppSettings["RadiusNearBySearch"] + "&types=" + objNearByServicesRequest.Types + "&keyword=" + objNearByServicesRequest.Keyword;
sURL += "&key=" + WebConfigurationManager.AppSettings["GoogleAPIKeyNearBySearch"];

String strreturn = String.Empty;


using (var client = new WebClient())
using (var stream = client.OpenRead(sURL))
using (var reader = new StreamReader(stream))
{
var jObject = Newtonsoft.Json.Linq.JObject.Parse(reader.ReadToEnd());
Console.WriteLine((string)jObject["results"][0]["vicinity"]);
}


I want to display out out in json format for 2 field like below.
how can I write code for display out put in below format using C#.

[
{
"id": 1,
"vicinity": "Opp. Railway Station, Gabba Estate,, Gohar Baug, Mumbai",

},
{
"id": 2
"vicinity": "SH 15, Navjivan Colony, Mumbai",

}

]

What I have tried:

how can I write code for display out put in below format using C#.

[
{
"id": 1,
"vicinity": "Opp. Railway Station, Gabba Estate,, Gohar Baug, Mumbai",

},
{
"id": 2
"vicinity": "SH 15, Navjivan Colony, Mumbai",

}

]
Posted
Updated 22-Dec-16 21:42pm

1 solution

You already posted this question at Near by place search using Google api[^], and received some suggestions.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900