使用Xamarin(Android)从某个位置请求POI [英] Requests POI from a location using Xamarin (Android)

查看:73
本文介绍了使用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...

这篇关于使用Xamarin(Android)从某个位置请求POI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆