0

Google のルート案内を使用してルート案内を取得しようとしていますが、次のエラーが発生します。

エラー ドメイン=org.brautaset.JSON.ErrorDomain コード=3 \"認識できない先頭文字 (41)\

ここにJsonがあります

loadDirections('Avenida Paulista', 'Rua Augusta', { 'locale': 'en', travelMode: G_TRAVEL_MODE_WALKING, avoidHighways: false, getPolyline: true, getSteps: true, preserveViewport: false})

何が間違っていますか?認識されない主人公 (41)とはどういう意味ですか?

 - (void)loadWithStartPoint:(NSString *)startPoint endPoint:(NSMutableArray *)endPoints options:(UICGDirectionsOptions *)options {
for (int idx = 0; idx < [endPoints count];idx ++) 
{
    NSString* msg = [NSString stringWithFormat:@"loadDirections('%@', '%@', %@)", startPoint, [endPoints objectAtIndex:idx], [options JSONRepresentation]];
    NSLog(@"msg %@",msg);
    mstr = [msg retain];
    [self performSelector:@selector(loadDirections:)  withObject:nil afterDelay:0.5];
}
}
 -(void)loadDirections:(NSString *)message
{
[googleMapsAPI stringByEvaluatingJavaScriptFromString:mstr];

}

4

2 に答える 2

1

JSONが無効です。

{ 
  'locale': 'en', 
  travelMode: "G_TRAVEL_MODE_WALKING", 
  avoidHighways: false, 
  getPolyline: true, 
  getSteps: true, 
  preserveViewport: false
}

これはG_TRAVEL_MODE_WALKINGと関係があると思いますが、引用符で囲む必要があります。有効なJSON値は次のとおりです

  • オブジェクト({}
  • 配列([]
  • 価値
    • 文字列("this is a string"
    • 番号1/-1
    • true
    • false
    • null

JSONドキュメント

于 2012-12-19T16:44:06.863 に答える
1

GDirectionsオブジェクトを初期化するときに、2番目のパラメーターとして実際の要素も渡すようにしてください。

ドキュメントに記載されているように:

運転(デフォルト)や徒歩などの移動モード。歩行方向を指定する場合は、ユーザーへの警告通知を保持するためのパネルを指定する必要があることに注意してください。

Map-Kit-Route-Directions拡張機能を使用している場合は、 api.htmlファイルを開き、 16行目でこれに置き換えます。

gdir = new GDirections(null, null);

これとともに

gdir = new GDirections(null, "body");
于 2013-01-17T14:58:50.043 に答える