- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
因为我使用了我的定位按钮和这个方法...
[mapView.settings setMyLocationButton:YES];
//AddObserverForDriverCurrentLocation
[mapView addObserver:self forKeyPath:@"myLocation" options:NSKeyValueObservingOptionNew context:NULL];
[self.view addSubview:mapView];
dispatch_async(dispatch_get_main_queue(), ^{
mapView.myLocationEnabled = YES;
});
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:
(NSArray<CLLocation *> *)locations
{
NSLog(@"Locations:%@",[locations lastObject]);
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if([keyPath isEqualToString:@"myLocation"]) {
CLLocation *location = [object myLocation];
NSLog(@"Location, %@,", location);
CLLocationCoordinate2D target =
CLLocationCoordinate2DMake(22.7,75.8);
[mapView animateToLocation:target];
[mapView animateToZoom:17];
}
}
但是当我点击 myLocation 按钮时,它没有更新我的位置,请帮忙
最佳答案
试试这个
要移动到当前位置,您必须:
mapView.myLocationEnabled = YES;
然后您可以在您的 viewWillAppear
方法中设置一个键值观察器,然后您可以使用 GoogleMaps SDK 的位置管理器更新您的位置。
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// Implement here to check if already KVO is implemented.
...
[mapView addObserver:self forKeyPath:@"myLocation" options: NSKeyValueObservingOptionNew context: nil]
}
然后观察属性。
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:@"myLocation"] && [object isKindOfClass:[GMSMapView class]])
{
[mapView animateToCameraPosition:[GMSCameraPosition cameraWithLatitude: mapView.myLocation.coordinate.latitude
longitude: mapView.myLocation.coordinate.longitude
zoom: mapView.projection.zoom]]; // check that the zoom property once
}
}
不要忘记在 viewWillDisappear 中注销您的观察者。
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
// Implement here if the view has registered KVO
...
[mapView removeObserver:self forKeyPath:@"myLocation"];
}
关于ios - mylocationButton 为什么不更新我的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34963174/
因为我使用了我的定位按钮和这个方法... [mapView.settings setMyLocationButton:YES]; //AddObserverForDriverCurrentLocati
我正在尝试制作一个具有不同 View 的滑出式导航应用程序。一种这样的 View 是谷歌地图。但是,当我运行该应用程序时,会出现“Google”水印,但缺少“我的位置”按钮。这与这篇文章非常相似goo
目前,myLocationButton 隐藏在按钮后面,如果您看一下按钮,myLocationButton 就在按钮后面。如何移动 myLocationButton 的 Y 位置? 最佳答案 使用 G
我已按照教程中的步骤操作如何通过 Google Maps SDK 获取用户的位置。我使用了Google提供的教程,也由Ray Wenderlich提供但这没有用。位置按钮甚至不显示。 任何帮助都会很棒
有人知道如何从 GMSMapView 实例中获取 myLocationButton 实例吗?或者改变默认位置的方法?我只需要将它向上移动一些像素。 最佳答案 根据此 Issue 5864: Bug:
这就是我如何启用我的位置按钮,以便可以在 map 上单击它: map.setMyLocationEnabled(true); 我的问题是,如何找到这个按钮并将其存储在一个变量中,以便根据我的应用程序的
我有一个完全可用的 GoogleMap,我可以通过调用显示我的用户位置 mMap.setMyLocationEnabled(true); 我想要完成的是实际点击现在出现在 GoogleMap 上的按钮
我是 iOS 开发的新手。我想创建一个自定义按钮,其功能与 Google Maps SDK for iOS 中的默认按钮 (myLocationButton) 相同。我可以这样做吗?我可以创建按钮,但
我想将 myLocationButton 放置在我的 iOS 应用程序的右上角,但似乎找不到方法。任何帮助将不胜感激 最佳答案 最简单的方法是为此 View Controller 或其 xib 添加一
我需要在我的 iOS 应用程序中使用的 Google Maps SDK 中更改 MyLocationButton 的位置。我试过了 for view in googleMap.subviews {
使用 Google 开发人员页面中的示例代码,我已将 map 实现到我的应用程序中。 map View 在导航 Controller 和标签栏 Controller 下。如何调整 map 大小使其不与
我是一名优秀的程序员,十分优秀!