我嘗試給用戶位置附近的5個註釋MKMapView ...我選擇隨機值註釋在我的didupdateuserlocation方法...當我運行我的projet所有5個註釋顯示在同一個地方的地球中心。 。它顯示在非洲附近的海域...任何人都可以幫助我更改不同的位置進行註釋。mapup for ios中的didupdateuserlocation方法?
- (void)mapView:(MKMapView *)mv didUpdateUserLocation:(MKUserLocation *)userLocation
{
CLLocationCoordinate2D userCoordinate = userLocation.location.coordinate;
for(int i = 1; i<=5;i++)
{
CGFloat latDelta = rand()*.035; ///RAND_MAX -5.0;
NSLog(@"%f",latDelta);
CGFloat longDelta = rand()*.03; ///RAND_MAX -5.0;
NSLog(@"%f",longDelta);
CLLocationCoordinate2D newCoord = { userCoordinate.latitude + latDelta, userCoordinate.longitude + longDelta };
MapPoint *mp = [[MapPoint alloc] initWithCoordinate:newCoord title:[NSString stringWithFormat:@"Azam Home %d",i] subTitle:@"Home Sweet Home"];
[mv addAnnotation:mp];
}
}
我印我的隨機values..they是
2012-01-02 20:27:32.229 ShareImg[749:15803] 588.244995
2012-01-02 20:27:32.230 ShareImg[749:15803] 8474257.000000
2012-01-02 20:27:32.231 ShareImg[749:15803] 56792752.000000
2012-01-02 20:27:32.231 ShareImg[749:15803] 29548310.000000
2012-01-02 20:27:32.231 ShareImg[749:15803] 40043812.000000
2012-01-02 20:27:32.231 ShareImg[749:15803] 14106338.000000
2012-01-02 20:27:32.231 ShareImg[749:15803] 3535964.000000
2012-01-02 20:27:32.232 ShareImg[749:15803] 43735528.000000
2012-01-02 20:27:32.232 ShareImg[749:15803] 51057228.000000
2012-01-02 20:27:32.232 ShareImg[749:15803] 60217132.000000
幫我這...
謝謝你們......在我的數據模型,我爲座標爲readonly..so說我不能改變我的值,直到now.i發現了一個屬性,清除我的問題..不管怎樣,謝謝你們兩位:-) .. – 2012-01-02 16:33:47