1
私はGMSPolygon * polygon = [GMSPolygon polygonWithPath:rect]を試しています。メソッドによって、ユーザがタップした座標のポリゴンを描画します。ここで私がクリックされた座標保存方法は次のとおりです。この後long/lat値に基づいてポリゴンを描画するための配列値の挿入方法 - Google Maps iOS?
// array made of clicked coordinates
NSMutableArray *latitudeTappedCoordinates = [NSMutableArray array];
NSMutableArray *longitudeTappedCoordinates = [NSMutableArray array];
NSUInteger numberOfLongitudeCoordinates = [longitudeTappedCoordinates count];
NSUInteger numberOfLatitudeCoordinates = [latitudeTappedCoordinates count];
for (int i = 2; i < numberOfLatitudeCoordinates; i++) {
[latitudeTappedCoordinates addObject:[NSNumber numberWithInt:coordinate.latitude]];
}
for (int i = 2; i < numberOfLongitudeCoordinates; i++) {
[longitudeTappedCoordinates addObject:[NSNumber numberWithInt:coordinate.longitude]];
}
を、私は次のようしている:
// polygon
GMSMutablePath *rect = [GMSMutablePath path];
[rect addCoordinate:CLLocationCoordinate2DMake(coordinate.latitude,coordinate.longitude)];
GMSPolygon *polygon = [GMSPolygon polygonWithPath:rect];
あなたが見ることができるように、ライン
[rect addCoordinate:CLLocationCoordinate2DMake(coordinate.latitude,coordinate.longitude)];
は、単一の属性になります。上記の配列initのすべての値を取り込んで、ポリゴンを描くことができます。どうやってやるの?
この私が得たエラーです:終了アプリによるキャッチされない例外に 'NSRangeException'、理由:「* ** - [__ NSArrayM objectAtIndex:]:空の配列の境界を超えるインデックス0 – konyv12
int i = 0をint i = 1に初期化して固定しました。 – konyv12
ただし、コードは機能しません。なぜどんなアイデア?私はマーカーを追加し続けますが、ポリゴンは描画されません。 – konyv12