我想开发一个应用程序,在这个应用程序中,我想通过获取用户的当前位置来显示用户附近(1公里内)的地方的信息。
例如,我想要显示与android设备当前位置相关的餐厅、购物中心、医院的信息。
我已经浏览过这个链接:Using Google Places API in Android..但是没有得到更多。
有人在android中使用过Google Places API吗?
发布于 2011-04-25 01:24:11
请记住以下几点:
keyString
=>是您的Google Map api密钥。urlString
是你想要用api key来签名的url,在代码中你会找到inputKey
和inputUrl
。这两个变量只是为了测试目的,如果你愿意,你可以省略它们。您可以直接编写代码,如下所示:URL url = new URL(urlString);
UrlSigner signer = new UrlSigner(keyString);
String request = signer.signRequest(url.getPath(),url.getQuery());
System.out.println("Signed URL :" + url.getProtocol() + "://" + url.getHost() + request);
在UrlSigner类的main方法中。
发布于 2012-02-07 17:50:19
API在印度运行良好(当然可以在全球任何地方运行)。你必须经历的是Google Places API。你可以简单地给谷歌一个你喜欢的用户当前位置和地点类型的url请求。
根据您的请求,响应可以是XML或Json。你所要做的就是把它解析出来。你可以在50公里内找到你周围的地方。关于url请求的一个例子是
https://maps.googleapis.com/maps/api/place/search/xml?location=9.934866,76.267235&radius=50000&types=country%7Cairport%7Camusement_park%7Cbank%7Cbook_store%7Cbus_station%7Ccafe%7Ccar_rental%7Ccar_repair%7Cchurch%7Cdoctor%7Cfire_station%7Cfood%7Chindu_temple%7Chospital%7Clawyer%7Clibrary%7Cmosque%7Cmuseum%7Cpark%7Cparking%7Cpharmacy%7Cpolice%7Cpost_office%7Crestaurant%7Cschool%7Ctrain_station%7Czoo&sensor=true&key=your_API_Key
*注意:%7C只是"|“。
发布于 2011-05-30 17:20:26
Google Places API在几周前公开了。
通过使用与安卓兼容的Google APIs Client Library for Java,您可以从安卓运行时使用Google Places API。
Google Places API REST API有很好的文档记录。有关使用Google APIs Client Library For Java和Google Places API的示例,请查看以下博客条目:
http://ddewaele.blogspot.com/2011/05/introducing-google-places-api.html
https://stackoverflow.com/questions/5551028
复制相似问题