android - 在 Google Places API 中传递当前位置(经度和纬度)

标签 android latitude-longitude google-places-api

我正在尝试将 Google Places API 集成到我的应用程序中。 现在我找到了手机的当前位置,如何将我得到的经度和纬度嵌入到以下 URL 而不是“location=34.0522222,-118.2427778”

“https://maps.googleapis.com/maps/api/place/search/xml?location=34.0522222,-118.2427778&radius=500&types=restaurants&sensor=false&key=Your_API_Key”

最佳答案

你的意思是你如何进行字符串操作,例如(未测试):

int latitude = ...;
int longitude = ...;
String preamble = "https://maps.googleapis.com/maps/api/place/search/xml?location=";
String postamble = "&radius=500&types=restaurants&sensor=true&key=";
String key = "Your_api_key";
String latStr = latitude + "";
String longStr = longitude + "";
String url = preamble + latStr + "," + longStr + postamble + key;

关于android - 在 Google Places API 中传递当前位置(经度和纬度),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10018033/

相关文章:

ios - 制作从谷歌下载的圆形照片(谷歌地点, swift )

android - 如何更改 EditText 和 Button 的高度?

map - 使用从笛卡尔空间和世界文件生成的纬度和经度计算多边形面积

google-maps - 如何更新所选地点类型的新标记..?

mysql - SQL:根据纬度/经度查找最近的邻居

ios - 获取带有经纬度的城市和国家名称(iOS)

ios - 一名委托(delegate)两类

android - 当我们开始生成发布版本时出现错误 : android defines classes that conflict with classes now provided by Android ,

android - 兼容性 : will an application with Android 2. 2 适用于装有 Android 2.0 或 2.1 的手机吗?

android - 子类房间实体