Focus the map on user location

This topic contains 5 replies, has 2 voices, and was last updated by  Guust 6 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: ,

  • Author
    Posts
  • #414546

    Paul Henderson
    Expired Member
    Post count: 55

    I am using the listing map in my application via gd-home page and shortcodes and it manually works OK. However, it is really inconvenient for users to have to zoom in to areas of interest.

    I want to be able to set the center point based on the user’s current location then set the zoom to show a reasonable area so that when they initially arrive on the map page so the default comes up to a useful area for the specific user. They can always change location or zoom back using the existing tools but the default should be their local ‘region’. Yes, I’m assuming that the lat/lon would be provided by the browser and/or mobile device.

    It seems that the capability is built in to geodirectory but I cant’ figure out how to do this, even if it takes custom code. Seems like a common need.
    Can anyone provide me instructions on how to set this up?

    #414549

    Guust
    Moderator
    Post count: 29970

    Please review https://wpgeodirectory.com/docs/search-filters-overview/#near

    You will need the Advanced Search addon, a SSL certificate, and the settings “Redirect to nearest location (on first time load users will be auto geolocated and redirected to nearest geolocation found)”

    You may also be interested in the “GD > Near Me Button” widget.

    Let us know how you went.

    #415068

    Paul Henderson
    Expired Member
    Post count: 55
    This reply has been marked as private.
    #415073

    Guust
    Moderator
    Post count: 29970

    Geolocation can only redirect to the location page.
    I suggest you add the “GD > Near Me Button” widget wherever you like and on the Location and Listings pages, add the Popular Categories widget, and it will link to the visitor’s most Listings pages closest to them.

    Thanks

    #416137

    Paul Henderson
    Expired Member
    Post count: 55

    Hi Guust,
    I tried the near me button and that works. I also tried just using a …/locations/me URL for that page and that does it too.

    One issue I’m still having, however. It seems that focusing on in the map with the Near Me or /locations/me actually automatically checks the Near Me box in Advanced Search then does the search using the diameter distance pre-set on the advanced search settings page.

    This is initially good as it brings the user to their map location with near listings shown, but causes one problem. I want the user to be able to start at their location on the map and see the listings in that near me area. This works. However I then want the user to be able to zoom out and pan to other locations on the map (I also have a preset location menu they can pick from) and see the listings in these new views.

    What I’m seeing for behavior in this case seems to be that the map moves to the right pan/zoom/location but the listings don’t show. It seems that the listings that show are based on the original near me query rather than showing all the listings in the the current location and zoom view as usually happens when you pan/zoom around the map and listing in the new view appear. Instead, no new listings appear, only the Near Me listings (now out of the view).

    After investigating more, per above, it seems that the Near Me checkbox is automatically checked when using the Near Me button or /locations/me. The user has not check it but it seems that the query has, and it does not automatically get unchecked. So now the subsequent pan/zoom operations are showing the desired map location, but still only showing the near me listings, which of course, are not within the view.

    So… assuming this is how it works (please tell me if I’m wrong), is there a way to automatically ‘uncheck’ the Near Me box after every Near Me query, or at least those queries triggered by /locations/me and Near Me button. My thinking is if this is cleared after the Near Me locations are show, then each subsequent pan/zoom or other non-Near-Me query will be independent. If a new zoom/pan location or other mechanism moves the map, it should display the listings in the view rather than be stuck on Near Me listings only.

    I was thinking this could potentially be done with an action hook. That is, if the Near Me is set by /locations/me or Near Me button, then after this is displayed, do a clean up by returning the Near Me check to unchecked. I see something in the docs about geodir_search_fields_after action but not sure that’s in the right location to do the job. I’ve not determined how to code this hook yet but wanted to see if this made any sense to you first.

    Please let me know your thoughts as to am I understanding correctly what is going on here? Is there a way to solve this as I’m suggesting or something easier? I’d appreciate any pointers. Thanks!

    #416168

    Guust
    Moderator
    Post count: 29970

    This explains how geolocation and the /location/me page works: https://wpgeodirectory.com/docs/search-filters-overview/#near

    1. the system will try to locate where the visitor is located
    2. if there are listings within the set search radius, a page will be served with those listings and the location of the visitor.

    So if you are in the center of London, the /location/me page will show listings NEAR YOUR location, and within the set radius. Not the listing IN the London location.

    You can reset by entering a different location to search, or selecting a different location in the Location Switcher, or providing a link to /location/ etc.

    Without seeing all your current settings it is hard to comment. Things that will affect the answer are
    where the visitor is located,
    the settings at GD > Multilocations > Home page should go to,
    the settings at GD > Permalinks > Add location in urls.

    Thanks

Viewing 6 posts - 1 through 6 (of 6 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket