Note that there are some explanatory texts on larger screens.

plurals
  1. PONot getting the proper map using MKMapVIew
    text
    copied!<p>I have created a mapview using <strong>MKMapView</strong>. Everything is working fine but there is a difference in the map which i am getting and which i was supposed to get. In my view map is coming but not properly i guess. please see the difference and let me know what is the problem . thanks Here's my <strong>ViewController.m</strong></p> <pre><code>#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; mapView=[[MKMapView alloc]initWithFrame:CGRectMake(0, 0, 320, 400)]; mapView.delegate=self; [mapView setMapType:MKMapTypeStandard]; [mapView setZoomEnabled:YES]; [mapView setScrollEnabled:YES]; MKCoordinateRegion region = { {0.0, 0.0},{0.0,0.0}}; region.center.latitude = 12.9667; region.center.longitude = 77.5833; region.span.longitudeDelta = 0.01f; region.span.latitudeDelta = 0.01f; [mapView setRegion:region animated:YES]; [self.view addSubview:mapView]; DisplayMap *annotation = [[DisplayMap alloc]init]; annotation.title = @" Bangalore"; annotation.subtitle = @"Silver Jublee Park"; annotation.coordinate = region.center; [mapView addAnnotation:annotation]; } -(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation: (id &lt;MKAnnotation&gt;)annotation { MKPinAnnotationView *pinView = nil; if(annotation != mapView.userLocation) { static NSString *defaultPinID = @"com.invasivecode.pin"; pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; if ( pinView == nil ) pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease]; pinView.pinColor = MKPinAnnotationColorRed; pinView.canShowCallout = YES; pinView.animatesDrop = YES; } return pinView; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } @end @implementation DisplayMap @synthesize coordinate,title,subtitle; -(void)dealloc{ [title release]; [subtitle release]; [super dealloc]; } @end </code></pre> <p><strong>ViewController.h</strong></p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import &lt;MapKit/MapKit.h&gt; @interface ViewController : UIViewController&lt;MKMapViewDelegate&gt; { MKMapView *mapView; } @end @class DisplayMap; @interface DisplayMap : NSObject &lt;MKAnnotation&gt; { CLLocationCoordinate2D coordinate; NSString *title; NSString *subtitle; } @property (nonatomic, assign) CLLocationCoordinate2D coordinate; @property (nonatomic, copy) NSString *title; @property (nonatomic, copy) NSString *subtitle; @end </code></pre> <p>I am getting the following map</p> <p><img src="https://i.stack.imgur.com/1nBRn.png" alt="enter image description here"></p> <p>I should get the following map</p> <p><img src="https://i.stack.imgur.com/CgnqX.png" alt="enter image description here"> </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload