2010-05-11 50 views

回答

0

你是否设置了?

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; 
} 
+0

我与showsUserLocation测试= YES。但我需要将蓝点设置为特定位置。 任何想法,示例代码? – fvisticot 2010-05-11 16:54:31

+0

编辑答案包括示例代码,看你如何去 – 2010-05-11 23:19:02

+0

谢谢你的帮助。 它不工作。 如果我理解的很好,animateToSelectPlace函数用于设置地图位置(以区域定义为中心)和动画。 我已经设置了mapView.showsUserLocation = YES,但不是蓝色点显示在地图的中心... 任何其他的想法? – fvisticot 2010-05-12 15:33:54

0

不确定是否可以设置CUSTOM用户位置(通常人们使用图像模拟蓝色用户点)。我虽然不是100%肯定,让你有机会尝试这样的事情来检查它是否能够应对用户位置与MKAnnotation ...

CLLocationCoordinate2D c = self.mapView.userLocation.location.coordinate; 
[[self.mapView userLocation] setCoordinate:c]; 
+0

'setCoordinate'方法是只读的。 – chicobermuda 2016-06-06 17:40:09

相关问题