Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8590735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:21:43+00:00 2026-06-11T23:21:43+00:00

Does anyone know how to use the rank by distance search option that is

  • 0

Does anyone know how to use the rank by distance search option that is mentioned here?
https://developers.google.com/maps/documentation/javascript/places#place_search_requests

Listing this in the request options doesn’t seem to work. Here’s my portion of code relative to this:

var request = {
  location: coords,
  //radius: 30000,
  keyword: ['puma, retail'],
  types: ['store'],
  rankBy: google.maps.places.RankBy.DISTANCE
};

service = new google.maps.places.PlacesService(map);
service.search(request, callback);

function callback(results, status) {
    if (status == google.maps.places.PlacesServiceStatus.OK) {
        for (var i = 0; i < results.length; i++) {
            createMarker(results[i]);
                            listResults(results[i]);
        }
    } 
}

Code will locate and list results if I include a radius, but the results aren’t listed in ascending order by distance. Google’s docs say a radius isn’t necessary either if using the rankBy option. Am I missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:21:45+00:00Added an answer on June 11, 2026 at 11:21 pm

    Was having the same problem.
    As per this source: http://www.geocodezip.com/v3_GoogleEx_place-search.html
    I was able to formulate the query as such:

    var request = {
    location: gps,
    types: ['food'], //You can substitute "keyword: 'food'," (without double-quotes) here as well.
    rankBy: google.maps.places.RankBy.DISTANCE, //Note there is no quotes here, I made that mistake.
    key: key 
    };
    

    Var key is API key which is not required but added for later use. GPS is:

    var gps = new google.maps.LatLng(location.lat,location.lon);
    

    Lastly, I did everything that you did except I added bounds to a map that I was not going to use. For that I did:

    var bounds = new google.maps.LatLngBounds();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how to use setLeftCapWidth on the mac? I know that Apple
Does anyone know how to use the subset.ff function in the ff package? Here
Does anyone know how to use the Google safe browsing API. I downloaded the
Does anyone know anyway to use something similar to polygon.getKml() except for the current
Does anyone know how to use an icon instead of text for the UINavigationController
Does anyone know how to use the command line compiler ('cl' and 'link') in
Does anyone know how to use different provider for membership? Actually i want to
I know I can use Request.Browser.IsMobileDevice . But does anyone know how it works,
Does anyone know of a method to use CRTP to count the number of
Does anyone know the syntax to use to add pattern styles to the cell

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.