Passing current location ( longitude and latitude ) in the Google Places API

Go To StackoverFlow.com

1

am trying to integrate Google Places API into my app. Now I am finding out my current location of the Phone, how do I embed the longitude and latitude which I have got into the following URL instead of "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"

2012-04-04 19:34
by santosh407


2

Do you mean how do you do string manipulation such as (untested):

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-05 02:40
by Colin
the value which i get is in integer/double type....and want to embedd that latitude and longitude in the URL... the solution which you provide is it working.... Between thank for the repl - santosh407 2012-04-05 08:37
I updated the untested example to show one way to convert from an integer to a String (fairly basic Java) - Colin 2012-04-06 02:17
I am trying to use GenericUrl class to add the latitude and longitude to url ..but how actually to use it....because its not importing any package as such.... - santosh407 2012-04-09 17:37
when using the above thing its showwing null results and STATUS CODE AS "INVALID REQUEST - santosh407 2012-04-11 09:39
thanks for the help i got my mistake.. - santosh407 2012-04-11 09:45


0

$lat = location[0];
$long = location[1];

Should work, but I use json for geting long and lat from google. Is better. I can check it again if not working.

Here is better json solution:

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

You should change Atlantis to address

2012-04-04 19:38
by Dudeist
I am trying to use GenericUrl class to add the latitude and longitude to url ..but how actually to use it....because its not importing any package as such.... - santosh407 2012-04-09 17:38
Ads