Retrieve coordinates while providing address

Support MB Geolocation Retrieve coordinates while providing addressResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #11408
    Aaryn EhlersAaryn Ehlers
    Participant

    I've looked everywhere, (well almost), for a PHP or shortcode function that uses geolocation to return the lat and lng coordinates when given an address. Does MB Geolocation provide a function? I'm not concerned with displaying the results , just getting the values themselves. I'll put the function in my child-theme functions.php file. I thought I could use a autocomplete custom item to store lat and lng fields for my posts that have the custom fields, and have tried to follow the instructions in the documentation, but I can't get that approach to work.

    #11421
    Anh TranAnh Tran
    Keymaster

    Hi Thomas,

    To use the Geolocation extension to retrieve latitude and longitude, please create 2 fields with ID lat and lng as follows:

    https://ghostbin.com/paste/5dpyd

    When you select an address from the suggestion list, the latitude and longitude are auto populated:

    https://i.imgur.com/LvTjaUG.png

    Then on the front end, you can use the rwmb_meta function to get their values.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.