Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在Google Places API中传递当前位置(经度和纬度)_Android_Latitude Longitude_Google Places Api - Fatal编程技术网

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

Android 在Google Places API中传递当前位置(经度和纬度),android,latitude-longitude,google-places-api,Android,Latitude Longitude,Google Places Api,我正在尝试将GooglePlacesAPI集成到我的应用程序中。 现在我正在查找手机的当前位置,如何将我获得的经度和纬度嵌入以下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\u API

我正在尝试将GooglePlacesAPI集成到我的应用程序中。 现在我正在查找手机的当前位置,如何将我获得的经度和纬度嵌入以下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\u API\u key“

应该可以,但我使用json从google获取long和lat。这样更好。如果不工作,我可以再次检查

以下是更好的json解决方案:


您应该将Atlantis更改为address

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


我得到的值是整数/双精度类型…并且希望在URL中嵌入纬度和经度。。。您提供的解决方案是否有效。。。。thank for the replyI更新了未经测试的示例,展示了从整数转换为字符串的一种方法(相当基本的Java).我正试图使用GenericUrl类将纬度和经度添加到url中..但实际如何使用它..因为它没有导入任何这样的包..当使用上述内容时,它显示空结果和状态代码为“无效请求”我正在尝试使用GenericUrl类将纬度和经度添加到url中。但是如何实际使用它…因为它不导入任何这样的包。。。。。
$lat = location[0];
$long = location[1];
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;