Reputation: 5565
I am working on a rails project. I need to get the current location of my GPS location in my system using a URL.
For example, to calculate the distance between two places, the following URL will give me a JSON data
I can code this in ruby as
uri = URI('http://maps.googleapis.com/maps/api/directions/json?origin=' + address1_enc + '&destination=' + address2_enc + '&sensor=false')
result = Net::HTTP.get(uri)
json=JSON.parse(result)
Likewise is there a URL by which I could get my current address or even latitude and longitude details in JSON format?
Upvotes: 1
Views: 1478
Reputation: 520
Sure, there are lots of services... For example:
http://ipinfodb.com/
https://www.telize.com/
or just google for "ip api"
I can recommend ipinfodb over telize. It is slower, but much more accurate (at least in my implementation).
Keep in mind, that when querying those APIs from your server you also share your quota with all other users on this server. So, let's say you are on heroku and you share one IP with multiple others, your quota limit will be reached soon. In this case, locate the user on the client-side.
Hope this helps
Upvotes: 1