使用Xamarin(Android)从某个位置请求POI
我正在尝试使用xamarin创建一个Android应用程序.我希望用户能够输入地址/位置并在其附近(在一定半径内)接收POI(兴趣点).
Im trying to create an android app with xamarin.I want the user to be able to input an address/location and receive POI (Points of Interest) near it (within a certain radius).
我知道google place api可以做到这一点,xamarin是否具有针对此类功能的内置功能?我可以以某种方式与Google Places API交互吗?
I know google places api can do this, does xamarin have built in capability for something like this? Can I somehow interface with the Google Places api?
还是我不知道的事情?感谢您的帮助!
Or is there something I don't know about? Thanks for the help!
使用HTTPWebRequest类创建对Google API的请求,代码段为:
Use HTTPWebRequest class to create a request to Google API, code snippet:
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();
}
}
copy over from here... pretty straightforward and simple...