[Solved] How to show Image over Map not as Pin but as seperate image? [duplicate]


You are looking for Map Overlay MKOverlayView.

Check these tutorials:

Creating overlay

  • Creating a MKOverlayView

Create a subclass of MKOverlayView like:

.h
#import
#import

@interface MapOverlayView : MKOverlayView
{
}
@end

.m

#import "MapOverlayView.h"

@implementation MapOverlayView

- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)ctx
{

    UIImage *image = [UIImage imageNamed:@"yourImage.png"];
    CGImageRef imageReference = image.CGImage;

    MKMapRect theMapRect = [self.overlay boundingMapRect];
    CGRect theRect = [self rectForMapRect:theMapRect];

    CGContextDrawImage(ctx, theRect, imageReference); 
}

@end
  • Adding Overlay

Implement the viewForOverlay: ,inside that create the overlay and add to map.

- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{

    MapOverlay *mapOverlay = (MapOverlay *)overlay;    
    MapOverlayView *mapOverlayView = [[[MapOverlayView alloc] initWithOverlay:mapOverlay] autorelease];

    return mapOverlayView;
}

1

solved How to show Image over Map not as Pin but as seperate image? [duplicate]