I try to do register the users limit to location. How I can after get location of user let to do register just in a city ? Thank for every ideas . I use a web api Project , when I get the data from android like this: { "UserName" : "Hosein.dafeyan" ,"Password" : "1234" , "Latitude": "32.629134" ,"Longitude":"51.646930" } And after then get in web api like a ViewModel, I check this location is in purpose city or no. After All then do return to android is valid or no.
-
1can you please share your code – Kiran Joshi Jul 04 '18 at 07:30
-
1You need to at least tell us how you are getting the location... – Hooman Bahreini Jul 04 '18 at 08:35
-
Please give a lot more detail. Do users type the location in a textbox, or do they select it from a Dropdown, or do you use Browser Location access? Show the code for your actual scenario. – Peter B Jul 04 '18 at 09:15
-
I use a web api Project , when I get the data from android like this: { "UserName" : "Hosein.dafeyan" ,"Password" : "1234" , "Latitude": "32.629134" ,"Longitude":"51.646930" } And after then get in web api like a ViewModel, I check this location is in purpose city or no. After All then do return to android is valid or no. – hosein dafeyan Jul 04 '18 at 16:31
3 Answers
You can use the Geocoding API by Google. The official document includes example requests and responses.
The Geocoding API is a service that provides geocoding and reverse geocoding of addresses.
Reverse geocoding is the process of converting geographic coordinates into a human-readable address.
You can make an HTTP GET request as follows:
https://maps.googleapis.com/maps/api/geocode/json?latlng=32.629134,51.646930&key=YOUR_API_KEY
If you don't know how to do this with C#, you can use these references in SO:

- 1
- 1
So when you want limited users per location. Then you have to this in steps
- Get Location info of user
- Get the already registered users count for that and if it's already reached the limit and if not let user get register.
So for
1. Get Location info of user
you can use this, Here is the Example
You can make ajax request to this and get back this info to your server to get user location
Note: though this approach has limitations that if user is using VPN or proxy site it will give you false data.

- 3,954
- 1
- 12
- 28
If you have GPS coordinates, check against a polygon that describes your acceptable area.

- 1,774
- 14
- 13