0
A
回答
1
由于显示当前位置作为注解的,我做了以下内容:
// Set up the annotation
LocationAnnotation *annotation = [[LocationAnnotation alloc] initWithLatitude:[numberFormatter numberFromString:[[location valueForKey:@"latitude"] description]] andLongitude:[numberFormatter numberFromString:[[location valueForKey:@"longitude"] description]] andTitle:[location valueForKey:@"name"] andSubtitle:[location valueForKey:@"notes"]];
[numberFormatter release];
[self.mapView addAnnotation:annotation];
诠释头类看起来是这样的:
@interface LocationAnnotation : NSObject <MKAnnotation> {
UIImage *image;
NSNumber *latitude;
NSNumber *longitude;
NSString *locationTitle;
NSString *locationSubtitle;
}
@property (nonatomic, retain) UIImage *image;
@property (nonatomic, retain) NSNumber *latitude;
@property (nonatomic, retain) NSNumber *longitude;
@property(nonatomic,retain) NSString *locationTitle;
@property(nonatomic,retain) NSString *locationSubtitle;
-(id)initWithLatitude:(NSNumber *)aLatitude andLongitude:(NSNumber *)aLongitude andTitle:(NSString *)aLocationTitle andSubtitle:(NSString *)aLocationSubtitle;
@end
的addAnnotation
方法和MKAnnotation
协议是你”重新寻找来实现这一点。
如果你想显示自定义位置,你会不会来围绕创建自己的MKAnnotation
这里提到:
1
确保您设置MKMapView
到YES
的showsUserLocation
财产。
此属性只有使显示用户位置。
相关问题
- 1. 显示用户位置
- 2. 在UITableview上显示位置
- 3. 如何显示在用户位置
- 4. 在Android中显示用户的位置
- 5. 在ViewDidAppear或ViewWillAppear调用becomeFirstResponder()的位置?
- 6. 使用ArcGis在OneMap上显示位置
- 7. 如何在所需位置显示mapkit蓝点(用户位置)?
- 8. 在显示特定位置MKMapkit后缩放到用户位置?
- 9. 用户的位置不显示在地图上
- 10. 在2D迷宫上显示用户位置 - Python
- 11. 获取用户在屏幕上显示的正确位置
- 12. 如何在Chrome扩展上显示用户位置?
- 13. 在表格上显示与用户最近的位置列表
- 14. 如何在网站上显示用户的位置(国家)?
- 15. 在mapview上显示用户所选位置
- 16. 如何在Google Maps iOS SDK上显示用户位置
- 17. 如何跟踪和显示用户在地图上的位置
- 18. 在用户的世界地图上显示地理位置
- 19. 根据用户的位置在MKMapView上显示注释
- 20. 放大显示当前用户位置
- 21. 显示当前用户位置?
- 22. 显示用户的位置Xcode6/IOS8
- 23. iOS Mapkit - 用户位置显示为0,0
- 24. 显示用户位置按钮 - Swift
- 25. 显示位置万岁用户地址
- 26. 根据用户位置显示结果
- 27. 根据用户位置显示天气
- 28. 根据用户位置显示自定义位置列表
- 29. android:在android地图上显示用户当前位置和当前位置附近的其他用户
- 30. UILabel只显示在viewDidAppear的viewcontroller
我知道这一点,但那不是我想要的。我想添加我自己的注释。 – deathman91
如何获取用户当前的纬度和经度viewDidAppear? – deathman91
您可以通过CLLocationManager的'coordinate'属性获取当前坐标 - 请参阅:http://developer.apple.com/library/ios/#DOCUMENTATION/CoreLocation/Reference/CLLocation_Class/CLLocation/CLLocation.html# // apple_ref/DOC/UID/TP40007126 –