Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #7 from rl1987/master

Slight improvements.
  • Loading branch information...
commit 3a313042defd698deca434097e8f667af8fffff2 2 parents 3f5afa8 + b45ae25
REVOLVER authored
Showing with 55 additions and 21 deletions.
  1. +55 −21 REVClusterMap/REVMapViewController.m
76 REVClusterMap/REVMapViewController.m
View
@@ -78,6 +78,28 @@ - (void)loadView
}
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
+ // e.g. self.myOutlet = nil;
+}
+
+- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
+{
+ [_mapView removeAnnotations:_mapView.annotations];
+ _mapView.frame = self.view.bounds;
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ // Return YES for supported orientations
+ return YES;
+}
+
+#pragma mark -
+#pragma mark Map view delegate
+
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if([annotation class] == MKUserLocation.class) {
@@ -90,43 +112,55 @@ - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnno
MKAnnotationView *annView;
if( [pin nodeCount] > 0 ){
- annView = (REVClusterAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"cluster"];
+ pin.title = @"___";
+
+ annView = (REVClusterAnnotationView*)
+ [mapView dequeueReusableAnnotationViewWithIdentifier:@"cluster"];
if( !annView )
- annView = (REVClusterAnnotationView*)[[[REVClusterAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"cluster"] autorelease];
+ annView = (REVClusterAnnotationView*)
+ [[[REVClusterAnnotationView alloc] initWithAnnotation:annotation
+ reuseIdentifier:@"cluster"] autorelease];
annView.image = [UIImage imageNamed:@"cluster.png"];
- [(REVClusterAnnotationView*)annView setClusterText:[NSString stringWithFormat:@"%i",[pin nodeCount]]];
- annView.canShowCallout = YES;
+
+ [(REVClusterAnnotationView*)annView setClusterText:
+ [NSString stringWithFormat:@"%i",[pin nodeCount]]];
+
+ annView.canShowCallout = NO;
} else {
annView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"pin"];
if( !annView )
- annView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pin"] autorelease];
+ annView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
+ reuseIdentifier:@"pin"] autorelease];
annView.image = [UIImage imageNamed:@"pinpoint.png"];
annView.canShowCallout = YES;
+
+ annView.calloutOffset = CGPointMake(-6.0, 0.0);
}
return annView;
}
-- (void)viewDidUnload
-{
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
-}
-
-- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
-{
- [_mapView removeAnnotations:_mapView.annotations];
- _mapView.frame = self.view.bounds;
-}
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+- (void)mapView:(MKMapView *)mapView
+didSelectAnnotationView:(MKAnnotationView *)view
{
- // Return YES for supported orientations
- return YES;
+ NSLog(@"REVMapViewController mapView didSelectAnnotationView:");
+
+ if (![view isKindOfClass:[REVClusterAnnotationView class]])
+ return;
+
+ CLLocationCoordinate2D centerCoordinate = [(REVClusterPin *)view.annotation coordinate];
+
+ MKCoordinateSpan newSpan =
+ MKCoordinateSpanMake(mapView.region.span.latitudeDelta/2.0,
+ mapView.region.span.longitudeDelta/2.0);
+
+ //mapView.region = MKCoordinateRegionMake(centerCoordinate, newSpan);
+
+ [mapView setRegion:MKCoordinateRegionMake(centerCoordinate, newSpan)
+ animated:YES];
}
@end
Please sign in to comment.
Something went wrong with that request. Please try again.