2

指定された座標の国で話されている言語を返す API を探しています。そのようなものが存在するかどうか誰かが知っていますか?

4

1 に答える 1

0

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);​

jsfiddleリンク

于 2012-08-06T13:15:00.853 に答える