iphone blue dot AND pin at same time -
please help, this question has been asked so many times before, but peoples suggestions have no effect on my outcome, all i want, is the pin and blue circle (Accuracy) to be shown on the map, here is my implementation. - oh, im using an iPhone device - im not in the simulator
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
NSLog(@"View for Annotation is called");
if (NSClassFromString(@"MKUserLocation")==[annotation class]) {
return nil;
}
if (annotation == mapView.userLocation) {
return nil;
}
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorGreen;
UIButton * btn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annView.rightCalloutAcces开发者_JAVA百科soryView = btn;
annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
pinDropped = TRUE;
return annView;
}
cheers in advance.... bloody thing
If you're using the Simulator then you're likely encountering the not-well-known difference in the way that CoreLocation and MapKit figure your current position.
In the Simulator
CoreLocation will always use Apple's headquarters in Cupertino, California, USA as your current location. This is where the blue dot will always appear on the map.
MapKit will always use something approximating your actual current location using Apple's database of IP address and WiFi hotspot information. This is where the map will center if you tell it to use your current location.
As a result, the map will center on your current location but the blue dot will be over in Cupertino.
On an iOS Device
CoreLocation puts the blue dot on something approximating your actual current location.
MapKit centers the map on something approximating your actual current location.
As a result you'll see the blue dot in the center of the map when using an actual iOS device.
This bit of knowledge can save a lot of stress. :)
just in case someone was wondering, this also works:
if ([annotation isKindOfClass:[MKUserLocation class]])
{
return nil;
}
This works in my code
if(annotation == mapView.userLocation){
return nil;
}
Try that and let us know
make sure implemented [mapview addAnnotation:annotation];
thanks Anna for the reminder.
精彩评论