sometimes you need the longitude and latitude of a place, be it for using it in a weather skin or searching nearby places.
mostly the Yahoo! api is used for that, but this service might be stopped any day. so as i played with a few apis while working on Evi, i thought i write these down. might be useful one day.
this list only has world-wide services that do not require an api-key and that do not require the query to be split up.
maybe one more piece of information: geo.places(0,1)
There can be more than one result (when you are for Paris for example), but if you want to read more results, you have to modify the request. here "0" is the start of the index, "1" is the number of results.
caution: something like geo.places(0,5) might mix up results even with conditional statements. (admin1 might not exist for the first result, but in the second, so a more sophisticated RegExp would be required)
maybe one more piece of information: geo.places(0,1)
There can be more than one result (when you are for Paris for example), but if you want to read more results, you have to modify the request. here "0" is the start of the index, "1" is the number of results.
caution: something like geo.places(0,5) might mix up results even with conditional statements. (admin1 might not exist for the first result, but in the second, so a more sophisticated RegExp would be required)
Yes, it can get complex quick, as some areas (particularly if you use a POI) don't have some info like admin1 / admin2 / locality1 / locatlity2 etc.
Looks like the api doesn't support it, but what would be really cool would be to enter a Lat/Long and have it "find" the nearest valid weather location code. Sometimes the closest "town/city" seems like it should be correct, but many folks could get even more accurate weather results since there are actually defined locations Yahoo knows about that are not intuitive to the user. For instance, my mailing address is "Fairfax", but "Chantilly" works better for accurate weather.
Lat and Long most folks can get from their phones...
moshi wrote:
maybe one more piece of information: geo.places(0,1)
There can be more than one result (when you are for Paris for example), but if you want to read more results, you have to modify the request. here "0" is the start of the index, "1" is the number of results.
caution: something like geo.places(0,5) might mix up results even with conditional statements. (admin1 might not exist for the first result, but in the second, so a more sophisticated RegExp would be required)
I actually kinda like the single return. Not only is it easier to parse, (by miles) it's not hard to use it that way. If you put in "paris" and meant "Paris Idaho" instead of "Paris France", you will get the wrong one and see that you need to narrow the search.
the old api could do reverse geocoding, pity it does no longer exist.
one solution would be to use Google (supports coordinates input) first: http://maps.googleapis.com/maps/api/geocode/xml?address=38.731602,-77.058563&sensor=false
and use the results to query Yahoo. that would need clever formatting and some testing about what input Yahoo accepts to make it work globally.