Jump to content
Larry Ullman's Book Forums

How to use geolocation and google map JavaScript


Recommended Posts

I have surf the web but still don’t find an explaining tutorial on how to use either google map or php google map to automatically detect the location of a user. This is what I want to achieve, during registration, a user current location will be extracted using either the js version of the map or the php version(depending on the one I saw a good way of using it), and extraction, the current town or city or village with also the country.

Who can really put me through on how to use any of the above library

Link to comment
Share on other sites

Here's a good starting point:

https://www.w3schools.com/html/html5_geolocation.asp

You have to do this in JS though, not PHP, and if the browser doesn't support navigator.geolocation, then you have to fall back on some PHP alternative, which is up to you to decide.

Please note that the Geolocation API is built into regular JS, and it's separate from the Google Maps API, which is provided by Google. However, if you use the Geolocation API to get the user's current location, then you can feed the acquired coordinates into the Google Maps API from there.

Make sense?

Link to comment
Share on other sites

 Share

×
×
  • Create New...