I want to show on the site (php) the user's location. How can I find out the coordinates most accurately?
2 answers
Ask the user to enter their coordinates :) In general, for this there is such a thing as IP GeoLocation. Dig on this keyword. But keep in mind that the data obtained in this way is not accurate and may in general not correspond to reality.
In addition, some browsers are able to provide such data .. and again the keyword GeoLocation. For example, geo-location-javascript . Again, there is no guarantee of accuracy.
- oneWell, you can provide the user with the received data, if you do not correspond to ask to enter his version. But all users hardly know their coordinates at the moment :)) - Tchort
- In general, at work IP geolocation usually shows fiction among people .. especially in international companies. At home, at least the city determines correctly. Normally, this is sufficient if you are not going to launch a rocket according to specified coordinates. - cy6erGn0m
- Damn, well now I am not going to :) I will dig api google maps :) Thank you - Tchort
In the presentation on HTML5 on the site of these guys: http://www.html5rocks.com/en/ saw the html5 component that shows your current location, ip essno, see how the component is made or use this component itself browsers are there too, but it is likely that this particular component will work in all browsers.
There is another option to use the Google Maps API or Yandex Maps API. The scheme is simple:
1) The user enters his address, the country there, the city and TP, (or selects the address from the drop-down menus)
2) The map can show where this place is, and also the map can give you geo-coordinates of a point, which, as far as I know, corresponds to the gps coordinates.