Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread Display Modes
Old Oct 23, 2009, 12:10 AM   #1
macrumors newbie
Join Date: Oct 2009
mapView doesn't seem to load map data on device

Hi guys,

Iíve been working on mapkit to start and zoom into my current location's region[some code based on the pragmatic bookshelf's iphone programming book]and Iíve encountered a rather bizzare problem.

Whenever I start the app on my iphone device,

1. it will load the world map,
2. then the blue dot will drop in
3. and the screen will attempt zoom in to where I am (Singapore).
4. But the map data does not load. I just get a grey grid screen with the blue location dot in the centre.

No amount of waiting seems to load the map.
mapViewWillStartLoadingMap is called. but mapViewDidFinishLoadingMap is not called. neither is mapViewDidFailLoadingMap.

To further compound this bizzare problem, I donít get that problem when I run it on the emulator.
However, it is to be noted that America is part of the world map loaded, while Singapore lies outside the boundaries of the world map that loads at the start.

Is this a bug? I've been working on it for a long time now but still remain clueless. did I miss out on something? Thanks!


#import "MapViewController.h"

@implementation MapViewController

@synthesize mapView;
@synthesize segCtrl_MapType;


- (IBAction) mapType:(UISegmentedControl *)segmentPick {
	switch (segmentPick.selectedSegmentIndex) {
		case 0:
			mapView.mapType = MKMapTypeStandard;
		case 1:
			mapView.mapType = MKMapTypeSatellite;
		case 2:
			mapView.mapType = MKMapTypeHybrid;

/**END IB ACTIONS******************/

//Zooms in the mapView on the user's current location
- (void)setCurrentLocation:(CLLocation *)location {
	MKCoordinateRegion region = {{0.0f, 0.0f}, {0.0f, 0.0f}};
	region.center = location.coordinate;
	region.span.longitudeDelta = 0.15f;
	region.span.latitudeDelta = 0.15f;
	[self.mapView setRegion:region animated:YES];
	//[mapView setRegion:MKCoordinateRegionMake([location coordinate], MKCoordinateSpanMake(.015f, .015f)) animated:YES];
//END SetCurrentLocation


//DELEGATE viewForAnnotation 
//Called whenever an annotation is being dropped on the map
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
	//NSLog(@"viewForAnnotation called");
	// the annotation being dropped is for the user's current locations
	if ([annotation isKindOfClass:[MKUserLocation class]])
		//NSLog(@"User Location");
		NSLog(@"Zooming in on user location");
		BOOL userLocationVisible = mapView.userLocationVisible;
		NSLog(@"userLocationVisible: %@\n", (userLocationVisible ? @"YES" : @"NO")); 
		NSLog(@"showUserLocation: %@\n", (mapView.showsUserLocation ? @"YES" : @"NO")); 

		CLLocation *location = [[CLLocation alloc] initWithLatitude:annotation.coordinate.latitude
														  longitude: annotation.coordinate.longitude];
		[self setCurrentLocation:location];
	else { //this is for any other annotation e.g.
		NSLog(@"Other Annotations");
		return nil; //TODO: change to annotate IMAGES.
	return nil;
//END viewForAnnotation

- (void)mapView:(MKMapView *)mapView	regionDidChangeAnimated:(BOOL)animated {
	NSLog(@"region did change");
	//TODO: Add photos around the region
	[fapi_request callAPIMethodWithGET:@"flickr.photos.search"  arguments:[NSDictionary dictionaryWithObjectsAndKeys:@"1", @"has_geo",@"geo,tags",@"extras",nil]];

- (void)mapViewWillStartLoadingMap:(MKMapView *)mapView {
	NSLog(@"map view will start to load map");

- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView {
	NSLog(@"map view finished loading map");


- (void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error {
	NSLog(@"map view failed to load map: %@",error.localizedDescription);

/**END MKMapView DELEGATES******************/

// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    return self;

// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
	//setup mapView
	mapView.delegate = self;
	mapView.showsUserLocation = YES;
	//setup locationmanager
	self.locationManager = [[[CLLocationManager alloc] init] autorelease];
	locationManager.delegate = self;
	[self.locationManager startUpdatingLocation];

	[super viewDidLoad];

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	// Release any cached data, images, etc that aren't in use.

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;

/**END UIViewController******************/

- (void)dealloc {
    [mapView release];
	[segCtrl_MapType release];
	[super dealloc];

quinton84 is offline   0 Reply With Quote
Old Oct 23, 2009, 02:47 PM   #2
macrumors Demi-God
KoolStar's Avatar
Join Date: Oct 2006
Location: Kentucky
Send a message via AIM to KoolStar Send a message via Skype™ to KoolStar
After it supposedly zooms in, if you zoom out do you get a map back. If so, you need to fix your zoom as it may be to close to have an image.
"Innovation distinguishes between a leader and a follower." : S.J.
KoolStar is offline   0 Reply With Quote
Old Oct 26, 2009, 05:29 AM   #3
Thread Starter
macrumors newbie
Join Date: Oct 2009
hi thanks for the help.

I don't think it's a zooming problem. I try to zoom out after it is zoomed in and the map does not load either. I tried 1.0f and 0.15f deltas and both did not work.

	MKCoordinateRegion region = {{0.0f, 0.0f}, {0.0f, 0.0f}};
	region.center = location.coordinate;
	region.span.longitudeDelta = 1.0f;
	region.span.latitudeDelta = 1.0f;
	[self.mapView setRegion:region animated:YES];
quinton84 is offline   0 Reply With Quote
Old Dec 28, 2009, 02:03 PM   #4
macrumors newbie
Join Date: Jun 2009
Possible Solution


I had the same issue and noticed that it stopped doing it if you explicitly define the mapType.

[aMKMapView setMapType:MKMapTypeStandard];
It is supposed to go to MKMapTypeStandard automatically, but after setting that value my map has seemed to load properly since.

Let me know if this helps!
cwe7976 is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Slow load of Mind Map Application burdekin Mac Applications and Mac App Store 3 Oct 30, 2013 06:25 AM
No data Map app truelies iPhone 5 Oct 4, 2012 11:27 AM
Why doesn't Apple's MAP app have navigation? Mikiesox iOS 6 2 Sep 20, 2012 09:33 AM
Get image data for pins on a MapView without blocking main thread problem pan17 iPhone/iPad Programming 4 Jul 25, 2012 07:26 PM

Forum Jump

All times are GMT -5. The time now is 05:53 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC