特定の郵便番号で利用可能な店舗を表示するアプリを開発しています。私は現在の場所から始めます。現在の場所に青い脈動するドットが表示されます。郵便番号を入力すると、マップビューに注釈を表示できます。現在地に戻ることができる「現在地」ボタンがあります。しかし、2回目は青い点が表示されませんか?どうすれば入手できますか、これはコードです:
- (void)showCurrentLocation
{
self.mapView.showsUserLocation = YES;
GPSAnnotation *annotation = [[GPSAnnotation alloc] initWithCoordinate:self.mapView.userLocation.coordinate];
annotation.title = @"Location";
[self.mapView addAnnotation:annotation];
[annotation release];
MKCoordinateRegion zoomIn;
zoomIn.center.latitude = self.mapView.userLocation.coordinate.latitude;
zoomIn.center.longitude=self.mapView.userLocation.coordinate.longitude;
zoomIn.span.latitudeDelta = .1f;
zoomIn.span.longitudeDelta =.1f;
self.mapView.showsUserLocation = YES;
[self.mapView setRegion:zoomIn animated:TRUE];
}
// annotation view
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(GPSAnnotation *)annotation
{
if ([[annotation title] isEqualToString:@"Location"])
{
MKAnnotationView *annotationView=[[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil] autorelease];
annotationView = [self.mapView dequeueReusableAnnotationViewWithIdentifier:@"blueDot"];
annotationView.annotation = annotation;
return annotationView;
}
else if ([annotation isKindOfClass:[MKUserLocation class]])
{
return nil;
}
}