放大用户位置
如何在我的应用程序中自动缩放 userLocation 上的地图? 我有以下代码可以在地图中缩放,但我必须缩放用户位置,并且以下代码始终缩放到非洲?
MKCoordinateRegion zoomIn = mapView.region;
zoomIn.span.latitudeDelta *= 0.2;
zoomIn.span.longitudeDelta *= 0.2;
zoomIn.center.latitude = mapView.userLocation.location.coordinate.latitude;
zoomIn.center.longitude = mapView.userLocation.location.coordinate.longitude;
[mapView setRegion:zoomIn animated:YES];
how can I zoom the map on my userLocation automatically in my app?
I have the following code to zomm in the map but i must zoom on the userLocation and the following code zooms always to africa?
MKCoordinateRegion zoomIn = mapView.region;
zoomIn.span.latitudeDelta *= 0.2;
zoomIn.span.longitudeDelta *= 0.2;
zoomIn.center.latitude = mapView.userLocation.location.coordinate.latitude;
zoomIn.center.longitude = mapView.userLocation.location.coordinate.longitude;
[mapView setRegion:zoomIn animated:YES];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,我使用以下委托方法解决了问题:
OK i solved the problem, with the following delegate Method:
非常感谢伙伴,这对我帮助很大。真的很想投票,但由于我的代表级别而不能投票。
我还发现使用:
总是将我缩放到非洲,并且从未将我集中到当前位置。
但通过使用委托方法:
我能够成功解决这个问题。我发现当使用mapView.userLocation.location.coordinate.latitude;时viewDidLoad 方法中的视图启动时没有触发正确的用户坐标,因此它显示了错误的坐标。
thanks alot mate, this helped me greatly. Really wanted to vote but cant because of my rep level.
I also found that using:
always zoomed me to africa, and never centered me onto my current location.
But by using the delegate method:
I was able to solve this successfully. What I discovered is that when using mapView.userLocation.location.coordinate.latitude; in the viewDidLoad method wasn't triggering the correct user coords on startup of the view, hence it was displaying the wrong coords.