私はグーグルマップの結果をキャッシュにマップしようとしています。問題は、最初の検索でデータ変数が常に未定義であることにあります。(同じ用語で)2回目の検索後にのみ結果が表示されます。誰でも問題を確認できますか?
if (!(me.data = me.googleSearchCache[ location ])) {
var geocoderRequest = {
address: location
}
geocoder.geocode(geocoderRequest, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
me.googleSearchCache[ location ] = $.map(results, function(loc) {
return {
value : loc.formatted_address,
//bounds : loc.geometry.bounds,
lat : loc.geometry.location.lat(),
lng : loc.geometry.location.lng()
};
});
}
});
}
data = me.googleSearchCache[ location ];
debug(data);