显示“蓝色定位销”当地图坐标改变时
有没有办法手动更新 MKMapView 上的当前位置并显示“蓝色标记图钉”来指示新位置?
(我在模拟器内完成所有这些操作,因为我还没有应用程序证书。)
我的 MKMapView 实例配置为“showsUserLocation”为 YES,当地图最初显示时,我看到“蓝色标记引脚” (总部位于库比蒂诺)。当用户点击“定位我”按钮时,我会使用 CLLocationManager 的实例执行 startUpdatingLocation。
当我收到新的位置更新时,我想调整地图上的“蓝色图钉”,但在地图上设置中心坐标似乎不起作用?
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
[self.mapView setCenterCoordinate:newLocation.coordinate animated:YES];
}
由于模拟器没有 GPS 功能,因此我手动发送新位置信息以使委托调用 'locationManager:didUpdateToLocation:fromLocation'
。
如何让蓝色图钉在地图上更新为指定坐标?
Is there a way to manually update the current location on MKMapView and have the 'blue marker pin' displayed to indicate the new spot?
(I'm doing all this with inside the simulator because I don't have my app certificate yet.)
My MKMapView instance is configured with 'showsUserLocation' as YES and when the map is initially shown, I see the 'blue marker pin' (based in Cupertino). When the user taps the 'locate me' button, I do a startUpdatingLocation with an instance of the CLLocationManager.
When I receive the new location update, I'd like to adjust the 'blue pin' on the map but setting the center coordinate on the map doesn't seem to do it?
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
[self.mapView setCenterCoordinate:newLocation.coordinate animated:YES];
}
Because the simulator doesn't have GPS functionality, I am manually sending the new location information to make the delegate call to 'locationManager:didUpdateToLocation:fromLocation'
.
How can I get the blue pin to update on the map with the specified coordinates?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能无法尝试在应用程序内手动更改设备的位置,但您可以更改 iOS 模拟器中的模拟位置:从模拟器的“调试”菜单中,选择“位置”,然后选择 Apple 的位置之一提供位置或输入坐标。
You probably won't have any luck trying to manually change the device's location from within your app, but you can change the simulated location in the iOS Simulator: From the simulator's Debug menu, select "Location", and then either choose one of Apple's provided locations or enter a coordinate.