http://www.geonames.org/export/web-services.html
CountryCode / reverse geocoding
The iso country code of any given point.
Webservice Type : REST
Url : api.geonames.org/countryCode?
Parameters : lat,lng, type, lang, radius (buffer in km for closest country in coastal areas, a positive buffer expands the positiv area whereas a negative buffer reduces it);
Result : returns the iso country code for the given latitude/longitude
With the parameter type=xml this service returns an xml document with iso country code and country name. The optional parameter lang can be used to specify the language the country name should be in. JSON output is produced with type=JSON
Example http://api.geonames.org/countryCode?lat=47.03&lng=10.2&username=demo
[more reverse geocoding webservices]
Url : api.geonames.org/countryCode?
Parameters : lat,lng, type, lang, radius (buffer in km for closest country in coastal areas, a positive buffer expands the positiv area whereas a negative buffer reduces it);
Result : returns the iso country code for the given latitude/longitude
With the parameter type=xml this service returns an xml document with iso country code and country name. The optional parameter lang can be used to specify the language the country name should be in. JSON output is produced with type=JSON
Example http://api.geonames.org/countryCode?lat=47.03&lng=10.2&username=demo
[more reverse geocoding webservices]
Ocean / reverse geocoding
The name of the ocean or sea.
Webservice Type : REST
Url : api.geonames.org/ocean?
Parameters : lat,lng, radius (optional)
Result : returns the ocean or sea for the given latitude/longitude
Example http://api.geonames.org/ocean?lat=40.78343&lng=-43.96625&username=demo
This service is also available in JSON format : api.geonames.org/oceanJSON?lat=40.78343&lng=-43.96625&username=demo
Url : api.geonames.org/ocean?
Parameters : lat,lng, radius (optional)
Result : returns the ocean or sea for the given latitude/longitude
Example http://api.geonames.org/ocean?lat=40.78343&lng=-43.96625&username=demo
This service is also available in JSON format : api.geonames.org/oceanJSON?lat=40.78343&lng=-43.96625&username=demo
FusionTables
Google Maps single country boundary
如何引发谷歌地图天气层标记点击?
I don't know if it works with google maps, but there is a web service that returns a country code and takes as parameters the lat and long.
Here is an example: http://ws.geonames.org/countryCode?lat=49.03&lng=10.2
var url = "http://ws.geonames.org/countryCode"; var center_lat = document.getElementById("lat").innerHTML ; var center_lng = document.getElementById("lng").innerHTML ; //25.302131077305933,121.5032958984375 fail var getData = 'lat='+ center_lat+"&lng="+center_lng ; //'lat='+ '49.03' +"&lng="+'10.2';// $.ajax({ type: "Get", url: url, data: getData, success: function(msg){ // alert( "Data Saved: " + msg ); }, error: function(msg){ } });
$url = "http://ws.geonames.org/countryCode?lat=49.03&lng=10.2"; $result = file_get_contents($url, false); echo $result;
var json_string = JSON.stringify(data);//'{"ocean":{"name":"Philippine Sea"}} '; var json_parsed = $.parseJSON(json_string); document.getElementById("where").innerHTML= json_parsed.ocean.name; //Philippine Sea
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。