使用 Google Places API
我想开发一个应用程序,在该应用程序中,我想通过获取用户的当前位置来显示用户附近(1 公里内)地点的信息.
I want to develop an application in which i want to display information about places nearby (within 1km )the user by getting its current location..
例如,我想显示与 android 设备的当前位置相关的 1 公里范围内的餐厅、购物中心、医院的信息..
Say for example i want to display information about Restaurants, Shopping Malls, Hospitals located within 1km related to current location of the android device..
我已经浏览过此链接:在 Android 中使用 Google Places API.. 但没有得到更多.
I have gone through this link : Using Google Places API in Android.. But didnt get more.
有人在安卓中使用过 Google Places API 吗?
Have anyone used Google Places API in android ?
需要牢记的几点:
- 要使用 Google 的 Places API,您需要注册并获取 Google 地图的 API 密钥.
- 在教程中的 UrlSigner 类中,变量描述为:
keyString
=> 是您的 Google Map api 密钥.urlString
是您要使用 api 密钥签名的 url. 在代码中你会发现
inputKey
和inputUrl
.这两个变量仅用于测试目的,您可以根据需要省略它们.可以直接写代码如下:
- In order to use Google’s Places API, you will need to register and obtain a Google Map’s API Key.
- In class UrlSigner in the tutorial the variable descriptions are:
keyString
=> is your Google Map api key.urlString
is the url you want to sign using the api key. In code you will find
inputKey
andinputUrl
. these 2 variables are just for testing purpose you can omit them if you want. You can directly write code as follows:
URL url = new URL(urlString);
UrlSigner signer = new UrlSigner(keyString);
String request = signer.signRequest(url.getPath(),url.getQuery());
System.out.println("签名网址:" + url.getProtocol() + "://" + url.getHost() + request);
在 UrlSigner 类的 main 方法中.
in main method of UrlSigner class.