我需要在GMSMapView上显示一个圆圈(与MKCircle一样).使用MKMapView和MKCircle时很容易,但不能将MKCircle与GMSMapView一起使用.有任何想法吗?
更新:
这是当前(18.03.2013)选项:
1.包含圆形图像的地面标记.
一个由几个部分组成的圆(折线).
编辑:
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];
Run Code Online (Sandbox Code Playgroud)
对于40x40像素的圆形图像,它看起来不错.(半径约为100米)
小分段路径解决方案:
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 = …Run Code Online (Sandbox Code Playgroud)