2
我正在查找一个API,它返回在给定坐标的国家/地区使用哪种语言。有谁知道这样的事情是否存在?Geocode to language
我正在查找一个API,它返回在给定坐标的国家/地区使用哪种语言。有谁知道这样的事情是否存在?Geocode to language
ws.geonames.org
提供此服务。下面是使用JavaScript和jQuery一些示例代码,但你可以用任何语言来访问它:
var lookupLanguagesWithGeonames = function(lat, lng) {
$.getJSON('http://ws.geonames.org/countryCode', {
lat: lat,
lng: lng,
type: 'JSON'
}, function(results) {
if (results.countryCode) {
alert('coordinates: ' + lat + ', ' + lng + '\n' + 'languages: ' + results.languages);
} else {
alert('coordinates: ' + lat + ', ' + lng + '\n' + 'failed: ' + results.status.value + ' ' + results.status.message);
}
});
};
// Coordinates that fall within a country
lookupLanguagesWithGeonames(43.7534932, 28.5743187);
// Coordinates which are not within any country
lookupLanguagesWithGeonames(142, 124);
协调,国家查找使用这样的回答: http://stackoverflow.com/a/3666861/317706在国内使用的语言: http://stackoverflow.com/a/1876170/317706 – user317706