How to get the latitude and longitude values of the Google Maps Autocomplete example?

Asked

Viewed 285 times

0

I’m using this example in the Lavarel form: https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform?hl=pt-br

Works well, I do the fields autocomplete, but wanted to auto complete with an input type Hidden the latitude and longitude.

How can I take latitude and longitude, using this example of the link, and put an Hidden input to store these two data in my database?

On my form, I’m trying to take it this way:

 <tr>
                            <td class="field-label"><b>Latitude</b></td>
                            <td class="wideField" colspan="3">
                                <input required class="field" name="latitude" id="lat" disabled="true"></input>
                            </td>
                        </tr>
  • 1

    In the callback of function navigator.geolocation.getCurrentPosition you get the latitude and longitude, then just assign to the inputs.

  • I tried id= but it didn’t take...

  • 1

    Put the code, which you used, here so we can assist you.

  • @Lucas edited the question with the HTML snippet at the end...

  • Ramos, please, in the question, also enter the code javascript.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.