开发者

Customise googlemap viewport in iphone

开发者 https://www.devze.com 2023-01-30 05:29 出处:网络
m stucked in figuring out how can i set the viewport for my google map markers. is there any way to 开发者_如何学编程do it in objC??

m stucked in figuring out how can i set the viewport for my google map markers.

is there any way to 开发者_如何学编程do it in objC??

or i have to do it in my map itself??? if yes, then how???

My code for google map just shows the maps along with the markers,but when i click it,it just shows the name of the place in a small box.. :(

how to make it a proper viewport???

here's the viewport image:

Customise googlemap viewport in iphone


1) You can subclass MKAnnotationView. I think it's the best way to solve your problem.

2) You can customize your annotation callout view, e.g:

- (MKAnnotationView *) mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation {
    static NSString* ItemAnnotationIdentifier = @"itemAnnotationIdentifier";
    MKPinAnnotationView* pinView = (MKPinAnnotationView *)
                                  [theMapView dequeueReusableAnnotationViewWithIdentifier:ItemAnnotationIdentifier];
    if (!pinView)
    {
      // if an existing pin view was not available, create one
      MKPinAnnotationView* customPinView = [[[MKPinAnnotationView alloc]
                                             initWithAnnotation:annotation 
                                             reuseIdentifier:ItemAnnotationIdentifier] 
                                            autorelease];
      customPinView.canShowCallout = YES;

      UIImage *logo = [ImageProcessor scaleImage:[UIImage imageNamed:@"logo.png"] toSize:CGSizeMake(30, 30)];
      customPinView.leftCalloutAccessoryView = [[[UIImageView alloc] initWithImage:logo] autorelease];

      UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
      rightButton.tag = [((ItemAnnotation *)annotation).itemId intValue];
      [rightButton addTarget:self
                      action:@selector(showDetails:)
            forControlEvents:UIControlEventTouchUpInside];
      customPinView.rightCalloutAccessoryView = rightButton;      

      return customPinView;
    }
    else
    {
      pinView.annotation = annotation;
    }
    return pinView;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消