C# 关于google places API
我想知道的是,使用Google places API。基本上我想创建一个像www.zomato.com这样的网站 1) 我可以像Google+商务页面一样,显示我所在城市的所有餐馆及其个人详细信息列表吗 2) 是否可以将此API与C#.net一起使用 3) Google将为此收取多少费用?如果我们查看,我们可以看到API请求返回的JSON格式。通过使用,我们可以轻松地生成一个C#模型来响应GooglePlaces查询C# 关于google places API,c#,api,C#,Api,我想知道的是,使用Google places API。基本上我想创建一个像www.zomato.com这样的网站 1) 我可以像Google+商务页面一样,显示我所在城市的所有餐馆及其个人详细信息列表吗 2) 是否可以将此API与C#.net一起使用 3) Google将为此收取多少费用?如果我们查看,我们可以看到API请求返回的JSON格式。通过使用,我们可以轻松地生成一个C#模型来响应GooglePlaces查询 public class Location { public doub
public class Location
{
public double lat { get; set; }
public double lng { get; set; }
}
public class Geometry
{
public Location location { get; set; }
}
public class OpeningHours
{
public bool open_now { get; set; }
public List<object> weekday_text { get; set; }
}
public class Photo
{
public int height { get; set; }
public List<string> html_attributions { get; set; }
public string photo_reference { get; set; }
public int width { get; set; }
}
public class Result
{
public Geometry geometry { get; set; }
public string icon { get; set; }
public string id { get; set; }
public string name { get; set; }
public OpeningHours opening_hours { get; set; }
public List<Photo> photos { get; set; }
public string place_id { get; set; }
public double rating { get; set; }
public string reference { get; set; }
public string scope { get; set; }
public List<string> types { get; set; }
public string vicinity { get; set; }
}
public class PlacesApiQueryResponse
{
public List<object> html_attributions { get; set; }
public List<Result> results { get; set; }
public string status { get; set; }
}
公共类位置
{
公共双lat{get;set;}
公共双精度{get;set;}
}
公共课几何
{
公共位置位置{get;set;}
}
公共课开放时间
{
公共bool open_now{get;set;}
公共列表工作日_text{get;set;}
}
公开课照片
{
公共整数高度{get;set;}
公共列表html_属性{get;set;}
公共字符串photo_引用{get;set;}
公共整数宽度{get;set;}
}
公开课成绩
{
公共几何体{get;set;}
公共字符串图标{get;set;}
公共字符串id{get;set;}
公共字符串名称{get;set;}
公共开放小时开放时间{get;set;}
公开列表照片{get;set;}
公共字符串place_id{get;set;}
公共双重评级{get;set;}
公共字符串引用{get;set;}
公共字符串作用域{get;set;}
公共列表类型{get;set;}
公共字符串{get;set;}
}
公共类PlacesApiQueryResponse
{
公共列表html_属性{get;set;}
公共列表结果{get;set;}
公共字符串状态{get;set;}
}
通过向GooglePlacesAPI发出一个简单的HTTP请求,我们就可以使用来反序列化查询结果
使用(var-client=new-HttpClient())
{
var response=await client.GetStringAsync(string.Format(“https://maps.googleapis.com/maps/api/place/nearbysearch/json?location={0},{1}&radius=500&type=bar&key=YourAPIKey”,纬度,经度);
var result=JsonConvert.DeserializeObject(响应);
}
如果我们查看,我们可以看到API请求返回的JSON格式。通过使用,我们可以轻松地生成一个C#模型来响应GooglePlaces查询
public class Location
{
public double lat { get; set; }
public double lng { get; set; }
}
public class Geometry
{
public Location location { get; set; }
}
public class OpeningHours
{
public bool open_now { get; set; }
public List<object> weekday_text { get; set; }
}
public class Photo
{
public int height { get; set; }
public List<string> html_attributions { get; set; }
public string photo_reference { get; set; }
public int width { get; set; }
}
public class Result
{
public Geometry geometry { get; set; }
public string icon { get; set; }
public string id { get; set; }
public string name { get; set; }
public OpeningHours opening_hours { get; set; }
public List<Photo> photos { get; set; }
public string place_id { get; set; }
public double rating { get; set; }
public string reference { get; set; }
public string scope { get; set; }
public List<string> types { get; set; }
public string vicinity { get; set; }
}
public class PlacesApiQueryResponse
{
public List<object> html_attributions { get; set; }
public List<Result> results { get; set; }
public string status { get; set; }
}
公共类位置
{
公共双lat{get;set;}
公共双精度{get;set;}
}
公共课几何
{
公共位置位置{get;set;}
}
公共课开放时间
{
公共bool open_now{get;set;}
公共列表工作日_text{get;set;}
}
公开课照片
{
公共整数高度{get;set;}
公共列表html_属性{get;set;}
公共字符串photo_引用{get;set;}
公共整数宽度{get;set;}
}
公开课成绩
{
公共几何体{get;set;}
公共字符串图标{get;set;}
公共字符串id{get;set;}
公共字符串名称{get;set;}
公共开放小时开放时间{get;set;}
公开列表照片{get;set;}
公共字符串place_id{get;set;}
公共双重评级{get;set;}
公共字符串引用{get;set;}
公共字符串作用域{get;set;}
公共列表类型{get;set;}
公共字符串{get;set;}
}
公共类PlacesApiQueryResponse
{
公共列表html_属性{get;set;}
公共列表结果{get;set;}
公共字符串状态{get;set;}
}
通过向GooglePlacesAPI发出一个简单的HTTP请求,我们就可以使用来反序列化查询结果
使用(var-client=new-HttpClient())
{
var response=await client.GetStringAsync(string.Format(“https://maps.googleapis.com/maps/api/place/nearbysearch/json?location={0},{1}&radius=500&type=bar&key=YourAPIKey”,纬度,经度);
var result=JsonConvert.DeserializeObject(响应);
}