13

GMSMapView に (MKCircle と同様に) 円を表示する必要があります。これは、MKMapView と MKCircle を使用すると簡単ですが、GMSMapView で MKCircle を使用することはできません。何か案は?

更新:
現在 (2013 年 3 月 18 日) のオプションは次のとおり
です。 1. 円の画像を含む地上マーカー。
2. 複数のセグメント (ポリライン) で作成された円。

編集:
3. Google が GMSCircle を追加 (23.04.2013)

 GMSGroundOverlayOptions *overlayOptions = [GMSGroundOverlayOptions options];
    overlayOptions.icon = [UIImage imageNamed:@"circle"];
    overlayOptions.position = touchMapCoordinate;
    overlayOptions.bearing = 0;
    overlayOptions.zoomLevel = 14.3;
 [mapView addGroundOverlayWithOptions:overlayOptions];

円の画像 40x40 ピクセルの場合、問題ないように見えます。(半径約100m)

小さなセグメント化されたパス ソリューション:

    GMSPolylineOptions *circle = [GMSPolylineOptions options];
    CGPoint touchPoint = [mapView.projection pointForCoordinate:touchMapCoordinate];
    GMSMutablePath *path = [GMSMutablePath path];

    CGPoint circlePoint;

    for (int i = 0; i < 360; i++)
    { 
        circlePoint.x = touchPoint.x + radius * cos(i*M_PI/180);
        circlePoint.y = touchPoint.y + radius * sin(i*M_PI/180);

        CLLocationCoordinate2D aux = [mapView.projection coordinateForPoint:circlePoint];
        [path addCoordinate:aux];
    }

    circle.path = path;
    circle.width = 1;

    [mapView addPolylineWithOptions:circle];

編集:2013年8月5日

GMSCircle ソリューション:

     CLLocationCoordinate2D circleCenter = CLLocationCoordinate2DMake(latitude, longitude);
     GMSCircle *circ = [GMSCircle circleWithPosition:circleCenter
                                     radius:1000];

     circ.fillColor = [UIColor blueColor];
     circ.strokeColor = [UIColor redColor];
     circ.strokeWidth = 5;
     circ.map = mapView;
4

3 に答える 3

1

現時点では、SDK は円をサポートしていませんが、ここに円を追加する機能のリクエストがあります。

https://code.google.com/p/gmaps-api-issues/issues/detail?id=4971

それまでの間、いくつかの短いセグメントでポリラインを描いて円を偽造することはできますか?

于 2013-03-15T23:36:20.137 に答える