Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
487 changes: 487 additions & 0 deletions 21551125林波/ios大作业/MyLBS/MyLBS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions 21551125林波/ios大作业/MyLBS/MyLBS/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// AppDelegate.h
// MyLBS
//
// Created by helmsmanmac on 15/9/2.
// Copyright (c) 2015年 helmsmanmac. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;


@end

52 changes: 52 additions & 0 deletions 21551125林波/ios大作业/MyLBS/MyLBS/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// AppDelegate.m
// MyLBS
//
// Created by helmsmanmac on 15/9/2.
// Copyright (c) 2015年 helmsmanmac. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

_window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
ViewController * viewController = [[ViewController alloc] init];
UINavigationController * navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[_window setRootViewController:navigationController];
[_window makeKeyAndVisible];

return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9059" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="MyLBS" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="548" y="455"/>
</view>
</objects>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
40 changes: 40 additions & 0 deletions 21551125林波/ios大作业/MyLBS/MyLBS/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>Code.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
17 changes: 17 additions & 0 deletions 21551125林波/ios大作业/MyLBS/MyLBS/MapViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// MapViewController.h
// MyLBS
//
// Created by helmsmanmac on 15/9/2.
// Copyright (c) 2015年 helmsmanmac. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@interface MapViewController : UIViewController

@property (nonatomic, strong) MKMapItem * mapItem;
@property (nonatomic) MKCoordinateRegion region;

@end
109 changes: 109 additions & 0 deletions 21551125林波/ios大作业/MyLBS/MyLBS/MapViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
//
// MapViewController.m
// MyLBS
//
// Created by helmsmanmac on 15/9/2.
// Copyright (c) 2015年 helmsmanmac. All rights reserved.
//

#import "MapViewController.h"

@interface MapViewController ()<MKMapViewDelegate>

@property (nonatomic, strong) MKMapView * mapView;
@property (nonatomic, strong) CLLocationManager * locationManager;

@end

@implementation MapViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
// Do any additional setup after loading the view.
[self setTitle:@"线路导航"];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回"
style:UIBarButtonItemStylePlain
target:self
action:@selector(returnPre)];

_mapView = [[MKMapView alloc] initWithFrame:self.view.frame];
[_mapView setShowsUserLocation:YES];
[_mapView setDelegate:self];
[self.view addSubview:_mapView];

MKPointAnnotation * annotation = [[MKPointAnnotation alloc] init];
annotation.coordinate = self.mapItem.placemark.location.coordinate;
[annotation setTitle:self.mapItem.name];
[_mapView addAnnotation:annotation];
[_mapView setRegion:[_mapView regionThatFits:self.region] animated:YES];

if(_locationManager == nil){
_locationManager = [[CLLocationManager alloc] init];

if([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]){
[_locationManager requestWhenInUseAuthorization];
}
}

// 确定自己的位置,并绘制一条路径到目的地
[self createLineFromCurrentSite:[MKMapItem mapItemForCurrentLocation] to:self.mapItem];
}

- (void)createLineFromCurrentSite:(MKMapItem *)fromItem to:(MKMapItem *)toItem {

MKDirectionsRequest * request = [[MKDirectionsRequest alloc] init];
// no表示只显示一条路径
[request setRequestsAlternateRoutes:NO];
[request setSource:fromItem];
[request setDestination:toItem];
MKDirections * directions = [[MKDirections alloc] initWithRequest:request];

// if(directions.calculating){
// [directions cancel];
// }

[directions calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error) {
if(error || response.routes == 0){
NSLog(@"error:%@",error);
}else{
for(MKRoute * rote in response.routes){
[_mapView addOverlay:rote.polyline level:MKOverlayLevelAboveRoads];
for(MKRouteStep * step in rote.steps){
NSLog(@"step:%@",step.instructions);
}
}
}
}];
}

- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay {
if([overlay isKindOfClass:[MKPolyline class]]){
MKPolylineRenderer * render = [[MKPolylineRenderer alloc] initWithPolyline:overlay];
[render setLineWidth:5.0];
[render setStrokeColor:[UIColor redColor]];
return render;
}else return nil;
}


- (void)returnPre {
[self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// ShowDataTableViewController.h
// MyLBS
//
// Created by helmsmanmac on 15/9/2.
// Copyright (c) 2015年 helmsmanmac. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ShowDataTableViewController : UITableViewController

@property (nonatomic, strong) NSString * searchString;

@end
Loading