[英]iOS Action, based on region in MapKit
Basically what I'm trying to accomplish is a GPS tour guide app, where when you enter a certain region and a sound file is played. 基本上,我要完成的是GPS导游应用程序,当您输入特定区域并播放声音文件时,该应用程序会在其中完成。
Let's say i've got 10 sound files and 10 regions. 假设我有10个声音文件和10个区域。
Is there a way to basically define a line on the map, and if the user crosses the line - the app changes the sound file being played? 有没有一种方法可以在地图上基本定义一条线,并且如果用户越过该线-应用会更改正在播放的声音文件?
Thanks 谢谢
MKMapViewDelegate
has a function mapView:regionDidChangeAnimated:
which occurs when user scrolls the map. MKMapViewDelegate
具有功能mapView:regionDidChangeAnimated:
当用户滚动地图时发生。 In this function you can switch music or whatever you need based on current map position (for example by checking which region is closer to the map center etc.): 在此功能中,您可以根据当前地图位置(例如,通过检查哪个区域更靠近地图中心等)来切换音乐或所需的任何内容:
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
/* do what you need with mapView.region */
}
Maybe - (void)startMonitoringForRegion:(CLRegion *)region desiredAccuracy:(CLLocationAccuracy)accuracy
on CLLocationManager
is what you are looking for. 也许
- (void)startMonitoringForRegion:(CLRegion *)region desiredAccuracy:(CLLocationAccuracy)accuracy
上CLLocationManager
是你在找什么。 You can define multiple regions -- as soon as the user enters one of the defined regions you will start to receive notifications. 您可以定义多个区域-用户输入定义的区域之一后,您将开始接收通知。 More info here
更多信息在这里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.