在室内设置当前位置 - Google Maps iOS SDK
问题描述:
现在,我已经使用Google Maps iOS sdk为我的室内地图添加了地面覆盖图,可以使用代码手动设置蓝点(用户当前位置)吗?在室内设置当前位置 - Google Maps iOS SDK
我似乎无法找到一种方法来做到这一点。很高兴看到一个示例代码片段。
答
基本上你需要检查显著位置的变化,可以有其中用户站立在特定位置为一分钟和的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];
}
这可能会有帮助。
答
这可有助于
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];
谢谢,想象“检测中心”每10秒钟会改变一次,有没有一种好的方法可以处理电池电量? – Gearbox
使用您的应用程序行走或驾驶的人是? – gurmandeep
只是走路而已 – Gearbox