//定位的按钮。
- (IBAction)dingWeiAction:(id)sender {
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(switchFocusImageItems) object:nil];
MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];
MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake(64.2323,32.3455) addressDictionary:nil] autorelease]];
toLocation.name = self.title;
[MKMapItem openMapsWithItems:[NSArray arrayWithObjects:currentLocation, toLocation, nil]
launchOptions:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:MKLaunchOptionsDirectionsModeDriving, [NSNumber numberWithBool:YES], nil] forKeys:[NSArray arrayWithObjects:MKLaunchOptionsDirectionsModeKey, MKLaunchOptionsShowsTrafficKey, nil]]];
[toLocation release];
}
就这一个方法就行了。当然要导入两个文件。#import "MapViewController.h"
#import <MapKit/MapKit.h>
其中MapViewController 是自己写的。
MapViewController.h :
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface MapViewController : UIViewController
@property (assign ,nonatomic) CLLocationCoordinate2D to;
@property (retain,nonatomic) NSString *shopName;
@end
MapViewController.m
#import "MapViewController.h"
#import <MapKit/MapKit.h>
@interface MapViewController ()
@end
@implementation MapViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];
MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[[MKPlacemark alloc] initWithCoordinate:self.to addressDictionary:nil] autorelease]];
toLocation.name = self.title;
[MKMapItem openMapsWithItems:[NSArray arrayWithObjects:currentLocation, toLocation, nil]
launchOptions:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:MKLaunchOptionsDirectionsModeDriving, [NSNumber numberWithBool:YES], nil]
forKeys:[NSArray arrayWithObjects:MKLaunchOptionsDirectionsModeKey, MKLaunchOptionsShowsTrafficKey, nil]]];
[toLocation release];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
相关推荐
使用iOS自带的定位代码,实现简单的定位
本篇文章主要介绍了IOS Core Location实现系统自带定位的方法,非常具有实用价值,需要的朋友可以参考下。
作者WSeniOS,源码SNLocation,iOS自带的定位还是不错的 为了用起来方便,封装了一份方便使用。
GetLocation手机自带定位,这个是安卓手机自带定位功能,或许有的手机不支持,但建议使用百度或高德定位
大头针,以及定位,iOS app ,自带大头针,以及自定义大头针的是小年方式,!
NULL 博文链接:https://zhangmingwei.iteye.com/blog/2017385
本文使用了苹果自带的类来实现定位 和反地理编码,简单便捷
操作系统:LInux、IOS、树莓派、安卓开发、微机操作系统、网络操作系统、分布式操作系统等。此外,还有嵌入式操作系统、智能操作系统等。 网络与通信:数据传输、信号处理、网络协议、网络与通信硬件、网络安全网络...
本demo是基于系统自带的MapKit实现的地位和目标大头针然后调用系统地图导航。建议真机运行,如果在模拟器上运行的话,请设置一下你的模拟器的经纬度
iOS系统地图MKMapView实现定位, 定制大头针, 圆形区域选择, 计算半径,
app内打开第三方地图进行导航<百度,高德,腾讯,苹果>iOS移动前段
iOS自带的定位还是不错的 为了用起来方便,封装了一份方便使用 https://github.com/WSeniOS/SNLocation
ios自带的高德地图 通过搜索定位到准确的地图位置 带有标注。
iOS系统自带的定位服务可以实现很多需求。比如:获取当前经纬度,获取当前位置信息等等。 其定位有3种方式: 1,GPS,最精确的定位方式 2,蜂窝基站三角定位,这种定位在信号基站比较秘籍的城市比较准确。 3,Wifi,...
本篇文章主要介绍了iOS开发系列--详解地图与定位,具有一定的参考价值,有需要的可以了解一下。
获取用户的经纬度,省市区街道的位置,苹果自带的定位,不牵扯第三方。
SAX 解析: 这是苹果系统自带的xml解析方法,特点就是:逐行解析, 这样方式效率低,但是可以快速的判断定位到哪一行出错。 DOM解析:全局解析,效率高,但是不容易定位到出错的位置。 3.个人总结 ...
一款适用于iOS App的线下测试工具集合。 【App信息查看】快速查看手机信息,App信息,权限信息的渠道,避免去手机设置查找或者查看项目源代码的麻烦。 【沙盒浏览】App内部文件浏览的功能,并且能通过airDrop或者...