简体   繁体   中英

Submit user location in a form

I'm trying to figure out how to get the location of someone filling out a web form on my site. I just want to get it down to a state level for US and Country for international(although state or equivalent is fine international too). I just don't want the user to have to select from a super long list or fill out a field. So ideally something like a hidden field that could have javascript or php pass the info to it.

Any ideas?

You can try; http://www.w3schools.com/html/html5_geolocation.asp

And using Google API: http://maps.googleapis.com/maps/api/staticmap?zoom=10&size=400x400&maptype=roadmap&markers=color:red%7Ccolor:red%7Clabel:C%7Cxx.xxxxxxx,xx.xxxxxxx&sensor=false

Using PHP or Javascript to replace the "xx.xxxxxxx"'s will give you a map of the users location.

You can probably use Google API to determine the users State, etc - as you mentioned. But I don't think you will be baby fed on this one.

You could try to figure out their location using their IP address . However, this is far from reliable. Unfortunately, if you need this data to be accurate, you're going to have to get them to give you their location.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM