#define METERS_PER_MILE 1609.344// Implement vIEwDIDLoad to do additional setup after loading the vIEw,typically from a nib.- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; mapVIEw.showsUserLocation=TRUE; // zoom to a specific area CLLocationCoordinate2D zoomLocation; zoomLocation.latitude = -28.994167; zoomLocation.longitude = 134.866944; MKCoordinateRegion vIEwRegion = MKCoordinateRegionMakeWithdistance(zoomLocation,1900*METERS_PER_MILE,1900*METERS_PER_MILE); MKCoordinateRegion adjustedRegion = [mapVIEw regionThatFits:vIEwRegion]; // make sure the Google water mark is always visible mapVIEw.autoresizingMask = (UIVIEwautoresizingFlexibleWIDth | UIVIEwautoresizingFlexibleHeight); [mapVIEw setRegion:adjustedRegion animated:YES]; mapVIEw.delegate=self; searchbar.delegate = self;}
这很好用.我添加了一个搜索栏和一个跳转到特定地址位置的函数.这也很好.我现在想要添加一个按钮来跳回当前位置.你可以帮我一把吗?
干杯
解决方法 您需要将地图的中心设置为点按该按钮的当前位置.说,像这样:- (IBAction)showCurrentLocation { [mapVIEw setCenterCoordinate:mapVIEw.userLocation.location.coordinate animated:YES];}总结
以上是内存溢出为你收集整理的iphone – 转到/缩放到当前位置功能(MapKit)全部内容,希望文章能够帮你解决iphone – 转到/缩放到当前位置功能(MapKit)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)