Hi,
Anyone knows how to retrieve the current city and state from the GPS coordinates?
Thanks
Hi,
Anyone knows how to retrieve the current city and state from the GPS coordinates?
Thanks
I haven’t done this but here’s how I think I could make it work.
Google “Reverse geocoding” and you will come across a number of scripts / services that return a street address when supplied with a GPS coord.
I would then put that in a simple php script (host it on my server) that receives a GPS coord from a caller (my mobile app), does the reverse geocoding php calls and return a json response to the caller.
Sounds like a neat challenge. Let me see if I can crack this one.
See https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding
You could simply call
http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true_or_false
And get a long JSON response on the calling mobile app and then go from there as well.
I like the php intermediary idea but it is not absolutely needed.
Thanks Kerem,
That would help a lot to make it easier for users.
Isn’t the google geocoding limited on the number of requests though?
Thanks
Atanas
Usage limits say you get 2500 lookups per 24 hours. If your mobile app is making the lookups directly then I think each mobile device running the app will count as one user so its really hard to consume all 2500 calls per day. If you go the php on server route you could hit the limit sooner or later so perhaps mobile calling Google api is better way in this case.
2500 isn’t as bad as I thought, but wasn’t the limit per appkey?
I seem to remember there were some free reverse geocoding sites as well?
Thanks,
Atanas
A call like this : http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true
gives me a response without requiring me to supply an appkey or any other identifier so I’m guessing they track the requests coming from IP addresses or other identifiers. This is why I’m hopeful each instance of your mobile app running on a device will be entitled 2500 calls max per day.
I see a number of other alternatives listed here :
Since you don’t need full address matching any of these should do. If you needed full address you would obviously want the service with best data which is quite likely Google.
Thanks a lot Kerem, will look them up
You are most welcome.
Also take a look at the MapView sample from CL (its in Samples/Interface folder). Current Location button uses the Map API to display the map of your current location but also returns address info. I believe this one relies on Apple data and it does not seem to be limited. Not sure if you can make use of this without showing the map etc but I suspect you could. Could be another option.
Shouldn’t this work for you? http://docs.coronalabs.com/api/type/Map/nearestAddress.html
If you don’t want to show the map, draw it off screen.
Rob
Thanks, I will try out how the performance is with loading the map offscreen.
Any way to retrieve the state too?
Thanks,
Atanas
I haven’t done this but here’s how I think I could make it work.
Google “Reverse geocoding” and you will come across a number of scripts / services that return a street address when supplied with a GPS coord.
I would then put that in a simple php script (host it on my server) that receives a GPS coord from a caller (my mobile app), does the reverse geocoding php calls and return a json response to the caller.
Sounds like a neat challenge. Let me see if I can crack this one.
See https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding
You could simply call
http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true_or_false
And get a long JSON response on the calling mobile app and then go from there as well.
I like the php intermediary idea but it is not absolutely needed.
Thanks Kerem,
That would help a lot to make it easier for users.
Isn’t the google geocoding limited on the number of requests though?
Thanks
Atanas
Usage limits say you get 2500 lookups per 24 hours. If your mobile app is making the lookups directly then I think each mobile device running the app will count as one user so its really hard to consume all 2500 calls per day. If you go the php on server route you could hit the limit sooner or later so perhaps mobile calling Google api is better way in this case.
2500 isn’t as bad as I thought, but wasn’t the limit per appkey?
I seem to remember there were some free reverse geocoding sites as well?
Thanks,
Atanas
A call like this : http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true
gives me a response without requiring me to supply an appkey or any other identifier so I’m guessing they track the requests coming from IP addresses or other identifiers. This is why I’m hopeful each instance of your mobile app running on a device will be entitled 2500 calls max per day.
I see a number of other alternatives listed here :
Since you don’t need full address matching any of these should do. If you needed full address you would obviously want the service with best data which is quite likely Google.
Thanks a lot Kerem, will look them up
You are most welcome.
Also take a look at the MapView sample from CL (its in Samples/Interface folder). Current Location button uses the Map API to display the map of your current location but also returns address info. I believe this one relies on Apple data and it does not seem to be limited. Not sure if you can make use of this without showing the map etc but I suspect you could. Could be another option.