动态更改iPhone地图中位置的纬度和经度
我如何动态获取纬度和经度,以便当用户从当前位置继续行走时,他在地图上的方向也应该不断变化。这怎么可能
how can i dynamically get the latitude and longitude so that when the user keeps on walking from his current position his direction on the map should also keep on changing.How is this possible
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你可以利用 MKMapview 的属性
showsUserLocation
取自 MKMapView 参考
shownUserLocation
一个布尔值,指示地图是否可以显示用户位置。
@property(nonatomic) BOOL 显示用户位置
讨论
该属性并不指示用户的位置在地图上是否实际可见,仅指示是否允许地图视图显示它。要确定用户的位置是否可见,请使用 userLocationVisible 属性。该属性的默认值为“否”。
将此属性设置为 YES 会导致地图视图使用核心位置框架来查找当前位置。只要此属性为“是”,地图视图就会继续跟踪用户的位置并定期更新。
I think you could make use of MKMapview's property
showsUserLocation
Taken from MKMapView Reference
showsUserLocation
A Boolean value indicating whether the map may display the user location.
@property(nonatomic) BOOL showsUserLocation
Discussion
This property does not indicate whether the user’s position is actually visible on the map, only whether the map view is allowed to display it. To determine whether the user’s position is visible, use the userLocationVisible property. The default value of this property is NO.
Setting this property to YES causes the map view to use the Core Location framework to find the current location. As long as this property is YES, the map view continues to track the user’s location and update it periodically.
作为 7KV7 答案的补充(我还不能直接回复答案),如果您需要知道它何时更新,请将 mapView:didUpdateUserLocation: 方法添加到您的委托中:
方法的文档
As an addition to 7KV7's answer (i can't respond to answers directly yet), if you need to know when it has updated, add the mapView:didUpdateUserLocation: method to your delegate:
method's documentation