Joh*_*n S 3 iphone map mapkit mkmapview ios
我有一个快速的问题.我使用自定义视图作为我的地图视图的标注附件.我有一些问题,让注释移动到所述视图的右下角.我目前正在尝试获得所选注释的CGPoint坐标,但除此之外,我已经画了一个空白任何帮助将不胜感激.
我正在使用的当前代码(我知道它是不正确的:)
CGPoint bottomLeftPoint = CGPointMake(xOffset,[self.internalAnnotationCallout view].frame.size.height);
CLLocationCoordinate2D bottomLeftCoord = [self.branchLocation convertPoint:bottomLeftPoint toCoordinateFromView:self.branchLocation];
MKCoordinateSpan span = {latitudeDelta: kMapMultiLatDelta, longitudeDelta: kMapMultiLatDelta};
MKCoordinateRegion region = {bottomLeftCoord, span};
[self.branchLocation setRegion:region animated:YES];
//[self.branchLocation setCenterCoordinate:newCenterCoordinate animated:YES];
Run Code Online (Sandbox Code Playgroud)
编辑:
好的,所以我把它搞砸了一下,并且能够将一些似乎有用的东西放在一起,希望我现在真正理解你想要实现的目标!
- (void)shiftToCorner{
//ignore "Annotation", this is just my own custom MKAnnotation subclass
Annotation *currentAnnotation = [[mapView selectedAnnotations] objectAtIndex:0];
[mapView setCenterCoordinate:currentAnnotation.coordinate];
CGPoint fakecenter = CGPointMake(20, 20);
CLLocationCoordinate2D coordinate = [mapView convertPoint:fakecenter toCoordinateFromView:mapView];
[mapView setCenterCoordinate:coordinate animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
让我快速解释一下它的作用; 假设您希望注释移动到距右边缘20个点,距离地图视图底部边缘20个点的位置.如果你考虑一下,如果当前注释位于地图视图的中心,那么到这一点的距离与到达(20,20)的距离相同.这意味着我们可以将注释发送到这一点,首先将我们的地图视图置于注释中心,然后设置为动画(20,20).
| 归档时间: |
|
| 查看次数: |
8603 次 |
| 最近记录: |