Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrajca committed Aug 23, 2010
0 parents commit 824650b
Show file tree
Hide file tree
Showing 22 changed files with 2,028 additions and 0 deletions.
19 changes: 19 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2010 Matt Rajca

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
32 changes: 32 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
MapKit
------

MapKit is an iOS 'library' for displaying tiled maps. While MKMapView has been bundled with iOS since version 3.0, it has lacked support for custom tile sources outside of Google Maps. While not a big issue for most developers, I have found some cool uses for displaying maps of Google Mars and Google Sky. Please be aware of licensing issues when using custom tile providers. I have only created this library as an exercise. The only built-in tile provider is OpenStreetMap. See [their page](http://wiki.openstreetmap.org/wiki/OpenStreetMap_License) for licensing information.

Usage
-----

To use MapKit in your project, simply drag the contents of the `Sources` folder into your iOS application project.

License
-------

Copyright (c) 2010 Matt Rajca

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
19 changes: 19 additions & 0 deletions Sample/Classes/SampleAppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// MapViewAppDelegate.h
// Sample
//
// Copyright Matt Rajca 2010. All rights reserved.
//

@class SampleViewController;

@interface SampleAppDelegate : NSObject < UIApplicationDelegate > {
@private
UIWindow *window;
SampleViewController *viewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet SampleViewController *viewController;

@end
30 changes: 30 additions & 0 deletions Sample/Classes/SampleAppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// MapViewAppDelegate.m
// Sample
//
// Copyright Matt Rajca 2010. All rights reserved.
//

#import "SampleAppDelegate.h"

#import "SampleViewController.h"

@implementation SampleAppDelegate

@synthesize window, viewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[window addSubview:viewController.view];
[window makeKeyAndVisible];

return YES;
}

- (void)dealloc {
[viewController release];
[window release];

[super dealloc];
}

@end
19 changes: 19 additions & 0 deletions Sample/Classes/SampleViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// SampleViewController.h
// Sample
//
// Copyright Matt Rajca 2010. All rights reserved.
//

@class MRMapView;

@interface SampleViewController : UIViewController {
@private
MRMapView *_mapView;
}

@property (nonatomic, retain) IBOutlet MRMapView *mapView;

- (IBAction)locateChicago:(id)sender;

@end
78 changes: 78 additions & 0 deletions Sample/Classes/SampleViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//
// SampleViewController.m
// Sample
//
// Copyright Matt Rajca 2010. All rights reserved.
//

#import "SampleViewController.h"

#import "MRMapView.h"
#import "MROSMTileProvider.h"

@interface SampleViewController ()

- (void)loadState;
- (void)saveState:(id)sender;

@end


@implementation SampleViewController

@synthesize mapView = _mapView;

- (void)viewDidLoad {
[super viewDidLoad];

_mapView.tileProvider = [[MROSMTileProvider new] autorelease];
[self loadState];
}

- (void)loadState {
_mapView.zoomLevel = [[NSUserDefaults standardUserDefaults] integerForKey:@"zoom"];

MRMapCoordinate center;
center.latitude = [[NSUserDefaults standardUserDefaults] doubleForKey:@"centerLat"];
center.longitude = [[NSUserDefaults standardUserDefaults] doubleForKey:@"centerLng"];

_mapView.center = center;

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(saveState:)
name:UIApplicationWillResignActiveNotification
object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(saveState:)
name:UIApplicationWillTerminateNotification
object:nil];
}

- (void)saveState:(id)sender {
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
[defs setInteger:_mapView.zoomLevel forKey:@"zoom"];

MRMapCoordinate center = _mapView.center;
[defs setDouble:center.latitude forKey:@"centerLat"];
[defs setDouble:center.longitude forKey:@"centerLng"];

[defs synchronize];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}

- (IBAction)locateChicago:(id)sender {
_mapView.zoomLevel = 10;
_mapView.center = MRMapCoordinateMake(41.85f, -87.65f);
}

- (void)dealloc {
[_mapView release];

[super dealloc];
}

@end
Loading

0 comments on commit 824650b

Please sign in to comment.