iOS Action,基于 MapKit 中的区域
基本上我想要完成的是一个 GPS 导游应用程序,当您进入某个区域时,就会播放声音文件。
假设我有 10 个声音文件和 10 个区域。
有没有一种方法可以在地图上基本上定义一条线,并且如果用户越过该线 - 应用程序会更改正在播放的声音文件?
谢谢
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.
Let's say i've got 10 sound files and 10 regions.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MKMapViewDelegate
有一个函数mapView:regionDidChangeAnimated:
,当用户滚动地图时会发生该函数。在此功能中,您可以根据当前地图位置切换音乐或任何您需要的内容(例如通过检查哪个区域更靠近地图中心等):MKMapViewDelegate
has a functionmapView:regionDidChangeAnimated:
which occurs when user scrolls the map. 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.):也许
CLLocationManager
上的- (void)startMonitoringForRegion:(CLRegion *)regiondesiredAccuracy:(CLLocationAccuracy)accuracy
就是您正在寻找的。您可以定义多个区域 - 一旦用户进入定义的区域之一,您就会开始接收通知。更多信息此处Maybe
- (void)startMonitoringForRegion:(CLRegion *)region desiredAccuracy:(CLLocationAccuracy)accuracy
onCLLocationManager
is what you are looking for. 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