Map view load based on their location

Home Forums Calendar Products Events Calendar PRO Map view load based on their location

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1045438
    dcantato
    Participant

    Where would I pass a variable for the users location to be automatically inserted so that the map would load events based on their location?

    I can get their location with the api: freegeoip.net/json/

    But I’m not sure where this would need to be passed through.

    Could I just insert it into somewhere like this and have the lat and lng in the values on ready?
    <div class=”tribe-bar-geoloc-filter”>
    <label class=”label-tribe-bar-geoloc” for=”tribe-bar-geoloc”>Near</label>
    <input type=”hidden” name=”tribe-bar-geoloc-lat” id=”tribe-bar-geoloc-lat” value=””>
    <input type=”hidden” name=”tribe-bar-geoloc-lng” id=”tribe-bar-geoloc-lng” value=””>
    <input type=”text” name=”tribe-bar-geoloc” id=”tribe-bar-geoloc” value=”” placeholder=”Location”>
    <div id=”tribe-geo-options” style=”display: none;”><div id=”tribe-geo-links”></div></div></div>

    like:
    $(‘tribe-bar-geoloc-lat’).value(‘userLat’)
    $(‘tribe-bar-geoloc-lng’).value(‘userLng’)

    #1045479
    George
    Participant

    Hey @dcantato,

    There’s unfortunately not a simple or straightforward way to go about this sort of customization 🙁 It’d require some rather complex rewriting of aspects of our code, which is information I’m sorry to have to share!

    If you’re not able to build this out yourself, I’d recommend hiring a professional developer like the ones we have listed here → http://m.tri.be/18k1

    Cheers!
    George

    #1045496
    dcantato
    Participant

    Can you point me in the direction of which files I should look over?

    #1046428
    dcantato
    Participant

    I found what I think should be a good temporary solution if anyone else is looking for a quick solution:

    $('#tribe-bar-geoloc').val('cityStateLoc')
    $(".tribe-events-button").click()

    If you call an api to get the users location and pass that into a city state variable called cityStateLoc you can have that called here and it will submit as if it was typed in.

    It’s a temporary solution until I dig deeper but it works.

    #1048264
    Brook
    Participant

    Howdy Dcanto,

    That’s a pretty good solution. There are two ways I personally would try to tackle this:

    1. HTTP Forward users to the location search URL. When you geocode the IP you will get back a lat, long, and name. Coincidentally our location searches need these three things, and append them to the URL:
      example.com/events/?tribe-bar-geoloc-lat=51.5073509&tribe-bar-geoloc-lng=-0.12775829999998223&tribe-bar-geoloc=London%2C+UK
      Using HTTP 302 redirects you could push users to the proper URL for location search in their area.
    2. Using JS you can insert the name of their location and search the first result, as you have done.

    Either way works! Let us know if you need anything else hear. As George said with this level of customization we’ll have to provide high level instructions and leave you or your developer to hash out the fine details. But we still love to help where we can. 🙂

    Cheers!

    – Brook

    #1048615
    George
    Participant

    I hope the (awesome!) code that Brook shared here helps @dcanto! For now, I will close up this specific thread. While we cannot help further with customizations, if any issues with the plugin arise open a new thread any time! 😀

    Happy New Year,
    George

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Map view load based on their location’ is closed to new replies.