1

Webサービスから82のアドレスを取得しており、フォワードジオコーダーを使用しています。次に、マップビューに一度に82個のアドレスすべてを表示する方法を説明します。コードをforループに入れましたが、「このAPIキーに対して行われたクエリが多すぎます」というエラーがスローされます。すべてのアドレスを送信し、すべてのアドレスの場所を取得する方法はありますか?これはforループの私のコードです...

 NSMutableDictionary *dictLoc = [[self.arrObjects objectAtIndex:indexValue]valueForKey:@"object_location"];

    NSString *searchString = [NSString stringWithFormat:@"%@,%@,%@,%@",[dictLoc valueForKey:@"object_location_number"],[dictLoc valueForKey:@"object_location_street"],[dictLoc valueForKey:@"object_location_city"],[dictLoc valueForKey:@"object_location_zip"]];

    //        if (self.forwardGeocoder == nil) {
    BSForwardGeocoder *forwardGeocoder = [[[BSForwardGeocoder alloc] initWithDelegate:self] autorelease];
    //        }

    CLLocationCoordinate2D southwest, northeast;
    southwest.latitude = 34.172684;
    southwest.longitude = -118.604794;
    northeast.latitude = 34.236144;
    northeast.longitude = -118.500938;
    BSForwardGeocoderCoordinateBounds *bounds = [BSForwardGeocoderCoordinateBounds boundsWithSouthWest:southwest northEast:northeast];

    // Forward geocode!
#if NS_BLOCKS_AVAILABLE
    [forwardGeocoder forwardGeocodeWithQuery:searchString regionBiasing:nil viewportBiasing:bounds success:^(NSArray *results) {
        [self forwardGeocodingDidSucceed:forwardGeocoder withResults:results withIndexValue:indexValue];
    } failure:^(int status, NSString *errorMessage) {
        if (status == G_GEO_NETWORK_ERROR) {
            [self forwardGeocoderConnectionDidFail:forwardGeocoder withErrorMessage:errorMessage];
        }
        else {
            [self forwardGeocodingDidFail:forwardGeocoder withErrorCode:status andErrorMessage:errorMessage];
        }
    }];
#else
    [self.forwardGeocoder forwardGeocodeWithQuery:searchString regionBiasing:nil viewportBiasing:nil];
#endif

前もって感謝します.. :)

4

2 に答える 2

1

コードをforループに入れましたが、「このAPIキーに対して行われたクエリが多すぎます」というエラーがスローされます。すべてのアドレスを送信し、すべてのアドレスの場所を取得する方法はありますか?

いいえ。このエラーは、使用しているAPIが実行できるクエリの数を制限していることを意味します。このエラーをgitで取り除き、あらゆる理由ですべての「82」ピンを表示する唯一の方法は、API開発者に連絡して、特定のAPIに対して実行できるクエリの数を増やす方法を見つけることです。時間枠。おそらくそれはプレミアムサービスであり、あなたはそのようなものにお金を払わなければならないでしょう。

現在、より良い解決策は、マップ上に82ピンを表示しないことです。これは、5/10のようなものの方がはるかにユーザーフレンドリーです。また、APIで1分あたり10クエリなどが許可される可能性があります。

さらにクールなソリューションは、コードが10個のクエリのように呼び出すことだけを許可するクエリキューを構築し、それから他のクエリをキューに入れることです。次に、割り当てられた時間の後、さらに10個のクエリを実行します。

于 2013-02-19T10:18:29.257 に答える
0

APIに従ってジオコーディングリクエストをバッチ転送できるようには見えません。

@interface BSForwardGeocoder : NSObject <NSURLConnectionDataDelegate>
- (id)initWithDelegate:(id<BSForwardGeocoderDelegate>)aDelegate;
- (void)forwardGeocodeWithQuery:(NSString *)searchQuery regionBiasing:(NSString *)regionBiasing viewportBiasing:(BSForwardGeocoderCoordinateBounds *)viewportBiasing;

#if NS_BLOCKS_AVAILABLE
- (void)forwardGeocodeWithQuery:(NSString *)searchQuery regionBiasing:(NSString *)regionBiasing viewportBiasing:(BSForwardGeocoderCoordinateBounds *)viewportBiasing success:(BSForwardGeocoderSuccess)success failure:(BSForwardGeocoderFailed)failure;
#endif

@property (nonatomic, assign) id<BSForwardGeocoderDelegate> delegate;
@property (nonatomic, assign) BOOL useHTTP;

@end

また、バッチジオコーディングリクエストを実行するAPIに出くわしたことはありませんが、リクエストの制限を高くする可能性のある別のAPI(GoogleジオコーディングAPI?)を試すことができます。

于 2013-02-19T10:24:39.503 に答える