现在我已经使用Google Maps iOS sdk为我的室内地图添加了地面叠加层,我可以使用代码手动设置蓝点(用户当前位置)吗?
我似乎找不到办法。很高兴看到一个示例代码段。
答案 0 :(得分:1)
这可能会有所帮助
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];
答案 1 :(得分:1)
基本上你需要检查重要的位置变化,可能存在用户站在特定位置一分钟的情况,并且将一次又一次地调用您正在使用的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地图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];
}
这可能会有所帮助。