Problem:
I would like to detect location of user who came to my website.
I am thinking about following:
- "Somehow detect" if user uses a mobile device with GPS module. If yes, then somehow (maybe using google maps) translate it from coordinates to "City, Street".
- If first option fails, then somehow search for geo location of $_SERVER['REMOTE_ADDR'].
Questions
- I assume that with first option I could retrieve exact address of user. With second option I am able to detect city in which provider operates. So if I want, for example, to display nearest bakery shops to user, I could not relay on that.
- Is this code suitable for first option location detection in web browser ?
- This Getting the location from an IP address seems to be best for the second option, am I right?