Ios [iPhone]在谷歌地图上围绕一个位置画一个圆圈
我不熟悉iPhone编程。我想使用CoreLocation和MapkitAPI编写一个应用程序。Ios [iPhone]在谷歌地图上围绕一个位置画一个圆圈,ios,mapkit,mkoverlay,Ios,Mapkit,Mkoverlay,我不熟悉iPhone编程。我想使用CoreLocation和MapkitAPI编写一个应用程序。 我已经能够找到并添加当前位置的PIN。现在,我试图在这个位置周围画一个圆圈,但我不知道该怎么做。谢谢你的指点。我想我也有同样的问题要问你。我找到了这个问题的答案,这对我帮助很大,我希望这会对你有所帮助。 我想我也有同样的问题要问你。我找到了这个问题的答案,这对我帮助很大,我希望这会对你有所帮助。 我知道它最初被标记为iOS SDK3.0,但我认为这是因为当时,这是当前的SDK。如果有人正在寻找答案,
我已经能够找到并添加当前位置的PIN。现在,我试图在这个位置周围画一个圆圈,但我不知道该怎么做。谢谢你的指点。我想我也有同样的问题要问你。我找到了这个问题的答案,这对我帮助很大,我希望这会对你有所帮助。
我想我也有同样的问题要问你。我找到了这个问题的答案,这对我帮助很大,我希望这会对你有所帮助。
我知道它最初被标记为iOS SDK3.0,但我认为这是因为当时,这是当前的SDK。如果有人正在寻找答案,但可以使用iOS 4.0+,那么我的解决方案如下 因此,我假设您有一个
UIViewController
,它拥有一个MKMapView
@interface MapViewController : UIViewController<MKMapViewDelegate> {
@private
MKMapView* mapView;
}
@property (nonatomic, retain) IBOutlet MKMapView* mapView;
@end
如果要自定义圆的外观,视图控制器可以实现MKMapViewDelegate
和mapView:viewForOverlay:
如下:
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay {
MKCircle* circle = overlay;
MKCircleView* circleView = [[[MKCircleView alloc] initWithCircle: circle] autorelease];
// make the circle red with some transparency and stroke
circleView.fillColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.25];
circleView.strokeColor = [UIColor redColor];
circleView.lineWidth = 2.0;
return circleView;
}
-(MKOverlayView*)地图视图:(MKMapView*)地图视图覆盖:(id)覆盖{
MKCircle*circle=叠加;
MKCircleView*circleView=[[MKCircleView alloc]initWithCircle:circle]autorelease];
//用一些透明度和笔划使圆圈变红
circleView.fillColor=[UIColor colorWithRed:1.0绿色:0.0蓝色:0.0阿尔法:0.25];
circleView.strokeColor=[UIColor redColor];
circleView.lineWidth=2.0;
返回回路视图;
}
请记住在视图控制器代码中设置
mapView.delegate=self
(例如viewDidLoad
)或通过界面生成器以图形方式进行设置。我知道这最初被标记为iOS SDK3.0,但我认为这是因为当时,这是当前的SDK。如果有人正在寻找答案,但可以使用iOS 4.0+,那么我的解决方案如下
因此,我假设您有一个UIViewController
,它拥有一个MKMapView
@interface MapViewController : UIViewController<MKMapViewDelegate> {
@private
MKMapView* mapView;
}
@property (nonatomic, retain) IBOutlet MKMapView* mapView;
@end
如果要自定义圆的外观,视图控制器可以实现MKMapViewDelegate
和mapView:viewForOverlay:
如下:
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay {
MKCircle* circle = overlay;
MKCircleView* circleView = [[[MKCircleView alloc] initWithCircle: circle] autorelease];
// make the circle red with some transparency and stroke
circleView.fillColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.25];
circleView.strokeColor = [UIColor redColor];
circleView.lineWidth = 2.0;
return circleView;
}
-(MKOverlayView*)地图视图:(MKMapView*)地图视图覆盖:(id)覆盖{
MKCircle*circle=叠加;
MKCircleView*circleView=[[MKCircleView alloc]initWithCircle:circle]autorelease];
//用一些透明度和笔划使圆圈变红
circleView.fillColor=[UIColor colorWithRed:1.0绿色:0.0蓝色:0.0阿尔法:0.25];
circleView.strokeColor=[UIColor redColor];
circleView.lineWidth=2.0;
返回回路视图;
}
记住在视图控制器代码中设置mapView.delegate=self
(例如viewDidLoad
),或通过界面生成器以图形方式设置