在mapKit中放置蓝色点,并带有所需位置
问题描述:
为了演示目的,我需要在Mapkit视图中模拟用户位置。 看来,使用未公开的API将蓝色点放置在地图视图的任何位置都是可能的。 不幸的是,我不知道巫婆无证API使用? 有什么帮助吗?在mapKit中放置蓝色点,并带有所需位置
答
你是否设置了?
mapView.showsUserLocation = YES;
设置一个特定的位置有点困难,但肯定可以在没有未记录的API的情况下使用。请参阅以下代码:
- (void)animateToSelectedPlace:(CGFloat)zoomLevel {
MKCoordinateRegion region;
region.center = [self getCoordinateFromComponents:chosenLatitude:chosenLongitude];
MKCoordinateSpan span = {zoomLevel,zoomLevel};
region.span = span;
[mapView setRegion:region animated:YES];
}
-(CLLocationCoordinate2D)getCoordinateFromComponents:(NSNumber*)latitude:(NSNumber*)longitude {
CLLocationCoordinate2D coord;
coord.latitude = latitude.doubleValue;
coord.longitude = longitude.doubleValue;
return coord;
}
答
不确定是否可以设置CUSTOM用户位置(通常人们使用图像模拟蓝色用户点)。我虽然不是100%肯定,让你有机会尝试这样的事情来检查它是否能够应对用户位置与MKAnnotation ...
CLLocationCoordinate2D c = self.mapView.userLocation.location.coordinate;
[[self.mapView userLocation] setCoordinate:c];
+0
'setCoordinate'方法是只读的。 – chicobermuda 2016-06-06 17:40:09
我与showsUserLocation测试= YES。但我需要将蓝点设置为特定位置。 任何想法,示例代码? – fvisticot 2010-05-11 16:54:31
编辑答案包括示例代码,看你如何去 – 2010-05-11 23:19:02
谢谢你的帮助。 它不工作。 如果我理解的很好,animateToSelectPlace函数用于设置地图位置(以区域定义为中心)和动画。 我已经设置了mapView.showsUserLocation = YES,但不是蓝色点显示在地图的中心... 任何其他的想法? – fvisticot 2010-05-12 15:33:54