Iphone 根据用户在iAction中的位置创建批注
我想在用户按下按钮时对其当前位置进行注释,我尝试了核心位置,但无法接受 这是一个例子:Iphone 根据用户在iAction中的位置创建批注,iphone,objective-c,map,mapkit,xcode4.5,Iphone,Objective C,Map,Mapkit,Xcode4.5,我想在用户按下按钮时对其当前位置进行注释,我尝试了核心位置,但无法接受 这是一个例子: -(IBAction)anotation:(sender){ CLLocationCoordinate2d *coor; MKUserlocation *ul; coor.latitude = **ul.location.latitude** //or something like that; ... ... } 您能帮助我吗?尝试此操作zoomToCu
-(IBAction)anotation:(sender){
CLLocationCoordinate2d *coor;
MKUserlocation *ul;
coor.latitude = **ul.location.latitude** //or something like that;
...
...
}
您能帮助我吗?尝试此操作zoomToCurrentLocation以单击按钮。getGotFix检查此回调设置的标志
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
这是IBAction代码(我确信上面有重复的代码)
}“我尝试过核心位置,但无法接受。”你这是什么意思?你完全可以做到这一点,我做了很多次。您遇到的确切问题是什么?如果要显示默认的蓝点,只需执行
mapView.showsUserLocation=YES代码>(您不应该显式创建MKUserLocation注释)。阅读如何?
- (IBAction)zoomToCurrentLocation:(id)sender
{
MKCoordinateRegion region;
if ([utils getGotFix] == YES)
{
region.center = self.mapView.userLocation.coordinate;
MKCoordinateSpan span;
span.latitudeDelta = 2; // Change these values to change the zoom 1 degree = 69 miles
span.longitudeDelta = 2;
region.span = span;
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(region.center, 2*METERS_PER_MILE, 2*METERS_PER_MILE);
MKCoordinateRegion adjustedRegion = [mapView regionThatFits:viewRegion];
[mapView setRegion:adjustedRegion animated:YES];
}
else
{ // We dont yet have a user location fix so inform user
UIAlertView * timeoutAlert = [[UIAlertView alloc] initWithTitle:@"No location fix" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[timeoutAlert show];
}