我想在地图视图中显示Google地图,我想在其中绘制多边形/圆形.
有什么建议?
好的,这实际上是一个线程中的三个不同的问题:
1)我正在使用:
- (void)viewDidLoad
{
[super viewDidLoad];
[mapView setFrame :CGRectMake(-100,-100,520,520)];
[mapView setAutoresizesSubviews:true];
mapView.showsUserLocation = YES;
locManager = [[CLLocationManager alloc] init];
locManager.delegate = self;
[locManager startUpdatingLocation];
[locManager startUpdatingHeading];
[bt_toolbar setEnabled:YES];
}
- (IBAction) CreatePicture
{
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(mapView.userLocation.coordinate.latitude, mapView.userLocation.coordinate.longitude);
CGPoint annPoint = [self.mapView convertCoordinate:coord toPointToView:self.mapView];
mapPic = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pic.png"]];
mapPic.frame = CGRectMake(annPoint.x, annPoint.y, 32, 32);
[self.view addSubview:macPic];
}
Run Code Online (Sandbox Code Playgroud)
使用GCRectMake在用户的坐标上放置图像,但遗憾的是图像没有放在正确的位置:
如果我移动地图,图片将始终放置与用户位置完全相同的偏移量.我错过了什么?它不应该直接放在用户上方吗?我猜测偏移量(-100,-100)我首先给出了mapView是导致这种情况的原因(我在下方有一个工具栏,因此偏移).
2)我的iOS 5模拟器表现得很疯狂,把我的位置放在凤凰城的格伦代尔(不应该是在Cupertino吗?)出于某种原因,并且因为我正在向东移动; 我的iPhone 4一切正常(除了不正确的图片放置).有任何想法吗?
3)我一直在考虑使用Annotations,但我听说它们是静态的(我真的需要它们是动态的).这是真的?
谢谢!