WP Store Locator
[resolved] Make the plugin wait to get users location before showing default results (4 posts)

  1. JFrankParnell
    Posted 2 years ago #

    Yes, I have the 'show all locations' off, but I mean, can you make it so that the results for the default location do not show until the users' location fails/declines?

    Presently, it seems to load the default location's results, then gets the user's location, then loads a new set of results. I dont want to see any results until either I accept the browser location prompt or if that is declined or fails, show me the default, then I can put in my current location.

    And really, I guess that it should be an option to show the default results at all. An option to wait for either browser location or manual input to show anything. Although, in that case, the 'show all' option should still work on the map, but not the results list. In this case, you'd get the map, with all the pins but nothing in the list until browser/manual location has been specified.


  2. Tijmen Smit
    Plugin Author

    Posted 2 years ago #

    What happens now is that if the user doesn't approve the location request after 3 sec it starts to load the store data, but it makes sense to change how to works. 3 sec is a bit to short now that I think of it. I will in one of the next versions make it an option to define the timeout time in the settings before the loading of store data is triggered.

    You can manually change the timeout value in the /js/wpsl-gmap.js file, then search for 'function checkGeolocation' and change the 3000 into whatever value you want. ( 3000 = 3sec ).

  3. JFrankParnell
    Posted 2 years ago #

    Ok, thanks. By putting in some large number, I can effectively not let it load any results until it gets a browser/manual location.

    I had originally wanted this to avoid user confusion about results lists populating then re-populating. But, this is also good because then I am hitting the google api less (by half) and not running out of free api hits.

  4. Tijmen Smit
    Plugin Author

    Posted 2 years ago #

    If you remove these lines completely from the 'checkGeolocation' function then it should just wait until the user approves it ( didn't test it ).

    locationTimeout = setTimeout( showStores, 3000 );
    clearTimeout( locationTimeout );

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Store Locator
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic