1

Google Places API をアプリに統合しようとしています。現在、電話の現在地を調べています。「location=34.0522222,-118.2427778」の代わりに、取得した経度と緯度を次の URL に埋め込むにはどうすればよいですか?

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

4

2 に答える 2

2

(テストされていない)次のような文字列操作をどのように行うのですか?

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;
于 2012-04-05T02:40:33.007 に答える
0
$lat = location[0];
$long = location[1];

動作するはずですが、私はグーグルから長くて緯度を取得するためにjsonを使用しています。優れている。動作しない場合は再度確認できます。

これがより良いjsonソリューションです:

http://maps.googleapis.com/maps/api/geocode/json?address=Atlantis&sensor=true&oe=utf-8

アトランティスをアドレスに変更する必要があります

于 2012-04-04T19:38:01.207 に答える