こんにちは、各ループの場所を取得しようとしています。Yahoo プレースメーカーは、配列のテキスト変数から場所を取得するために使用されます。各ループ内で場所を外部関数に送信していますが、値を取得していません。誰が何が間違っているのか知っていますか? ありがとう!
function replace_undefined(array, text_array) {
console.log(text_array);
for (i = 0, l = text_array.length; i < l; i++) {
var text = array[i].text;
Placemaker.getPlaces(text, function (o) {
console.log(o);
if ($.isArray(o.match)) {
if (o.match[0].place.name == "Europe" || o.match[0].place.name == "United States") {
var location = o.match[1].place.name;
getLocation(location);
}
if ($.isArray(o.match)) {
if (o.match[0].place.name !== "Europe") {
var location = o.match[0].place.name;
getLocation(location);
}
}
}
if (!$.isArray(o.match) && o.error == "no locations found") {
var location = "";
getLocation(location);
}
if (!$.isArray(o.match) && o.error !== "no locations found") {
var location = o.match.place.name;
getLocation(location);
}
});
}
function getLocation(n) {
return function () {
console.log('Location: ' + n);
};
}
}