Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's what you need to do:</p> <p>1.) Obtain the user's current location using GPS, here's <a href="https://stackoverflow.com/questions/3145089/what-is-the-simplest-and-most-robust-way-to-get-the-users-current-location-in-a/3145655#3145655">an answer that'll help you do that.</a></p> <p>2.) Next, figure out in what radius do you wish to display your results, i.e do you need results that are within 2 miles of the user's location or 5 miles or so on.</p> <p>3.) Figure out what this (refers to point 2) translates into in terms of latitude and longitude values, so basically you will have to define a bounding-box with a lowerLeftLatitude, lowerLeftLongitude, lowerRightLatitude, lowerRightLongitude. These calculations can be done by figuring out how much one longitude translates into in terms of miles (again, this calculation will probably be approximate because the distance between longitude changes from places to place due to the very nature of how longitudes work (read this: <a href="http://en.wikipedia.org/wiki/Longitude" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Longitude</a> if you wish to make adjustments based on each person's location)</p> <p>4.) Use the following method (it's a variant of getFromLocationName) instead of using the version that you are using right now: <a href="http://developer.android.com/reference/android/location/Geocoder.html#getFromLocationName(java.lang.String" rel="nofollow noreferrer">http://developer.android.com/reference/android/location/Geocoder.html#getFromLocationName(java.lang.String</a>, int, double, double, double, double). Read how this method works, basically you will be specifying the bounding box values as well now apart from the name (i.e McDonalds). So now, you will get more user-location-specific results.</p> <p>Let me know how it goes/ if you need more help</p> <p>Here's the code for getting the JSON response from the Places API: Once again <strong>DON'T</strong> forget to replace the "AddYourOwnKeyHere" with your Places API key</p> <pre><code>try { HttpPost httppost = new HttpPost("https://maps.googleapis.com/maps/api/place/search/json?location=34.730300,-86.586100&amp;radius=19308&amp;types=food&amp;name=mcdonalds&amp;sensor=false&amp;key=AddYourOwnKeyHere"); HttpClient httpclient = new DefaultHttpClient(); response = httpclient.execute(httppost); String data = EntityUtils.toString(response.getEntity()); JSONObject json = new JSONObject(data); //Parse the JSONObject now } catch (Exception e) { e.printStackTrace(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload