MKMapView userLocation,正确位置,错误坐标?

发布于 2024-10-22 05:28:35 字数 807 浏览 1 评论 0原文

我正在编写一个带有 MKMapView 的测试应用程序,该应用程序在应用程序启动时出现,在开始时我想初始化 mapView 以更适合用户所在的位置,因此我使用 userLocation 来获取“用户当前位置”

MKUserLocation *currentLocation = [[self mMapView] userLocation];
[[self mapView] setShowsUserLocation:YES];

这工作正常并将图钉放在正确的位置(所有这些都是地图缩小了)我有两个问题:

问题:(1)

MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([[currentLocation location] coordinate], 200, 200);
[[self mapView] setRegion:region];

即使注释当我尝试查询位置坐标时,大头针位于正确的位置(即 iOS 清楚地知道我在哪里),我只得到 [0.0000] 和 [0.0000]

问题:(2)

当我缩放或平移时地图上的图钉再次掉落,因此每次移动时都会获得新的图钉掉落动画。有办法阻止这种情况吗?

注意: 我稍后在代码中使用 CLLocationManager,这只是我在应用程序首次加载时快速尝试的操作,以便让用户更好地了解他们所在的位置,而不仅仅是查看默认缩小的谷歌地图。

I am writing a test application with an MKMapView that appears when the application starts, right at the start I want to initialise the mapView to be more appropriate to where the user is so I am using userLocation to get the the "users current location"

MKUserLocation *currentLocation = [[self mMapView] userLocation];
[[self mapView] setShowsUserLocation:YES];

This works fine and puts a pin in the correct place (all be it that the map is zoomed way out) I have two problems:

PROBLEM:(1)

MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([[currentLocation location] coordinate], 200, 200);
[[self mapView] setRegion:region];

Even though the annotation pin is in the correct place (i.e. iOS clearly knows where I am) when I try and query the location coordinate I just get [0.0000] and [0.0000]

PROBLEM:(2)

When I zoom or pan the map the pin drops again, so each time you move you get a new pin drop animation. Is there a way to stop this?

NOTE: I am using CLLocationManager later in my code, this was just something I was trying quickly when the application first loads to give the user a better feeling for where they were rather than just looking at the default zoomed out google map.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

別甾虛僞 2024-10-29 05:28:35

问题1的解决方案。
嘿,它在设备上运行良好......在模拟器中它会显示为(0,0)

Solution for prob 1.
Hey it works fine at the Device ..... In simulator it will show you as (0,0)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文