使用 Xamarin 从某个位置请求 POI (Android)
Requests POI from a location using Xamarin (Android)
我正在尝试创建一个 android 应用 xamarin.I 希望用户能够输入 address/location 并在其附近(在特定时间内)接收 POI(兴趣点)半径)。
我知道 google 个地方 api 可以做到这一点,xamarin 是否内置了这样的功能?我能以某种方式与 Google 地点 api 交互吗?
或者有什么我不知道的?感谢您的帮助!
使用 HTTPWebRequest class 创建对 Google API 的请求,代码片段:
private void button1_Click(object sender, EventArgs e)
{
HttpWebRequest webRequest = WebRequest.Create(@"https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=7500&types=library&sensor=false&key=AIzaSyD3jfeMZK1SWfRFDgMfxn_zrGRSjE7S8Vg") as HttpWebRequest;
webRequest.Timeout = 20000;
webRequest.Method = "GET";
webRequest.BeginGetResponse(new AsyncCallback(RequestCompleted), webRequest);
}
private void RequestCompleted(IAsyncResult result)
{
var request = (HttpWebRequest)result.AsyncState;
var response = (HttpWebResponse)request.EndGetResponse(result);
using (var stream = response.GetResponseStream())
{
var r = new StreamReader(stream);
var resp = r.ReadToEnd();
}
}
从here复制过来...非常简单明了...
我正在尝试创建一个 android 应用 xamarin.I 希望用户能够输入 address/location 并在其附近(在特定时间内)接收 POI(兴趣点)半径)。
我知道 google 个地方 api 可以做到这一点,xamarin 是否内置了这样的功能?我能以某种方式与 Google 地点 api 交互吗?
或者有什么我不知道的?感谢您的帮助!
使用 HTTPWebRequest class 创建对 Google API 的请求,代码片段:
private void button1_Click(object sender, EventArgs e)
{
HttpWebRequest webRequest = WebRequest.Create(@"https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=7500&types=library&sensor=false&key=AIzaSyD3jfeMZK1SWfRFDgMfxn_zrGRSjE7S8Vg") as HttpWebRequest;
webRequest.Timeout = 20000;
webRequest.Method = "GET";
webRequest.BeginGetResponse(new AsyncCallback(RequestCompleted), webRequest);
}
private void RequestCompleted(IAsyncResult result)
{
var request = (HttpWebRequest)result.AsyncState;
var response = (HttpWebResponse)request.EndGetResponse(result);
using (var stream = response.GetResponseStream())
{
var r = new StreamReader(stream);
var resp = r.ReadToEnd();
}
}
从here复制过来...非常简单明了...