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 8895689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:50:54+00:00 2026-06-14T23:50:54+00:00

I am using the geocoder gem’s .nearby method to query my DB and return

  • 0

I am using the geocoder gem’s .nearby method to query my DB and return nearby location objects.

Question 1: When loading the map for the first time, no markers are passed to the JS, and it does not load the map. How can I fix this issue without loading a marker?

<script type="text/javascript">
Gmaps.map = new Gmaps4RailsGoogle();
Gmaps.load_map = function() {
Gmaps.map.map_options.detect_location = true;
Gmaps.map.map_options.center_on_user = true;
Gmaps.map.initialize();
Gmaps.map.markers = ; // BLOWS UP HERE
Gmaps.map.markers_conf.list_container = "markers_list";
Gmaps.map.create_markers();
Gmaps.map.adjustMapToBounds();
Gmaps.map.callback();
};
Gmaps.oldOnload = window.onload;
 window.onload = function() { Gmaps.triggerOldOnload(); Gmaps.loadMaps(); };
</script>`

Question 2: When user searches and no nearby results are available to their search, how to recover from this just showing a random location (right now it loads the middle of the ocean).

Question 3: When user searches and no nearby results are available, can I show nearby locations to their current location using browser geolocation (I know it’s not supported in all browsers).

  • 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-14T23:50:55+00:00Added an answer on June 14, 2026 at 11:50 pm

    Answer 1:

    There is no bug in the gem.

    This line of yours makes javascript cry:

    @json = nil
    

    Indeed nil isn’t valid json.

    You should do:

    @json = [].to_json
    

    Answer 2

    If your query doesn’t return anything, Make another one to get a random object. Can’t see any problem there.

    Answer 3

    Geolocation from browser is included in the gem, you even have a callback on success. See code. But you’ll have to write your own javascript fitting your own logic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the android.location.Geocoder for the first time. The Idea is: I have a
I am using the Geocoder class to fetch multiple location objects by using the
Using CI for the first time and i'm smashing my head with this seemingly
I am using geocoder and the devise gem. And i am trying to get
I'm using gem mongoid_special instead of mongoid_geo . Main question is how to geocode
I am using the gem 'geocoder'. I am trying to make an object that
I have difficulties with the search location radius function using with geocoder and a
I am using the Geocoder.getLocationFromName() method on both the emulator and my phone (Nexus
I am using Google geocoder for lat and lon and my question is, is
I'm using google.maps.Geocoder to get viewport . Then I want to create google.maps.Map so

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.