[英]Set Current Location in Indoors - Google Maps iOS SDK
现在,我已经使用Google Maps iOS sdk为室内地图添加了地面叠加层,是否可以使用代码手动设置蓝点(用户当前位置)?
我似乎找不到办法。 很高兴看到示例代码片段。
这可能会有所帮助
CLLocationCoordinate2D inspectionCenter = CLLocationCoordinate2DMake(markerLocation.coordinate.latitude, markerLocation.coordinate.longitude);
GMSMarker *marker = [[GMSMarker alloc] init];
marker.title = [NSString stringWithFormat:@""];
marker.position = inspectionCenter;
marker.appearAnimation = kGMSMarkerAnimationPop;
marker.map = mapView;
NSString *imageName=[NSString stringWithFormat:@"yourimage"];
marker.icon = [UIImage imageNamed:imageName];
基本上,您需要检查重大的位置更改,在某些情况下,用户可能会在特定位置站立一分钟,然后会反复调用您使用的NSTimer或逻辑10秒钟。 为此,您需要按照以下步骤检查重要的位置更改。
if (nil == locationManager)
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
//Configure Accuracy depending on your needs, default is kCLLocationAccuracyBest
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
// Set a movement threshold for new events.
locationManager.distanceFilter = 500; // meters, set according to the required value.
[locationManager startUpdatingLocation];
您无法使用Google Maps SDK完全做到这一点,必须使用CLLocationManger框架来获取位置更新。
初始化locationManager以注册重大的位置更改并正确设置委托
位置经理的代表:
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations {
// If it's a relatively recent event, turn off updates to save power.
CLLocation* location = [locations lastObject];
NSDate* eventDate = location.timestamp;
NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
if (abs(howRecent) < 15.0) {
// Update your marker on your map using location.coordinate by using the GMSCameraUpdate object
GMSCameraUpdate *locationUpdate = [GMSCameraUpdate setTarget:location.coordinate zoom:YOUR_ZOOM_LEVEL];
[mapView_ animateWithCameraUpdate:locationUpdate];
}
这可能会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.