有一种简单的方法可以隐藏它吗?我使用用户位置,但我不想显示蓝点。我怎么能隐藏它?
- 编辑 -
我使用了错误的东西吗?
@interface ALMapaViewController : UIViewController <MKMapViewDelegate,
MKAnnotation>
{
IBOutlet MKMapView *mapaPrincipal;
id<ALMapaViewControllerDelegate> delegateMap;
CLLocationCoordinate2D coordinate;
}
我的.m
@implementation ALMapaViewController
- (void)viewDidLoad{
[super viewDidLoad];
[mapaPrincipal setMapType:MKMapTypeStandard];
[mapaPrincipal setZoomEnabled:YES];
[mapaPrincipal setScrollEnabled:YES];
[mapaPrincipal.userLocation addObserver:self
forKeyPath:@"location"
options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
context:nil];
[mapaPrincipal setShowsUserLocation:YES];
}
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
MKCoordinateRegion region;
region.center = mapaPrincipal.userLocation.coordinate;
MKCoordinateSpan span;
span.latitudeDelta = 0.005f;
span.longitudeDelta = 0.005f;
region.span = span;
[mapaPrincipal setRegion:region animated:YES];
self.coordinate = region.center;
[mapaPrincipal addAnnotation:self];
[mapaPrincipal setShowsUserLocation:NO];
}
@end
我已经使用了showUserLocation
,它仍然显示蓝点。
答案 0 :(得分:7)
您希望接收用户位置更新,但不显示蓝点。
一种选择是使用CLLocationManager
来获取更新而不是地图视图的showsUserLocation
。在位置管理器上调用startUpdatingLocation
并实施其locationManager:didUpdateToLocation:fromLocation:
委托方法。
如果您不想使用CLLocationManager
,另一个选项是隐藏地图视图创建的用户位置视图,方法是将其hidden
属性设置为YES
地图视图的didAddAnnotationViews
委托方法。地图视图将继续接收用户位置更新(因为您不将showsUserLocation
设置为NO
)但蓝点不会显示,因为您正在隐藏其视图
此答案中显示了第二个选项的示例:
Hide MKUserLocation when MKMapView showsUserLocation == YES
一个不相关的点是,您不需要使用键值观察来监视对地图视图的userLocation
属性的更改。请改用mapView:didUpdateUserLocation:
委托方法。
答案 1 :(得分:6)
非常简单的伙伴
[mapView setShowUserLocation:NO];
答案 2 :(得分:0)
您可以在didAddAnnotationViews委托方法中隐藏用户位置的视图:
(void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
MKAnnotationView *ulv = [mapView viewForAnnotation:mapView.userLocation];
ulv.hidden = YES;
}
答案 3 :(得分:0)
您可以使用此方法
[mapViewSelf setShowsUserLocation:NO];
答案 4 :(得分:0)
这很好。
SELECT SCN_TO_TIMESTAMP(ORA_ROWSCN) LAST_OPERATION_TIME,
T.*
FROM YOUR_TABLE T
WHERE SCN_TO_TIMESTAMP(ORA_ROWSCN) BETWEEN START_TIMESTAM AND END_TIMESTAMP;