2016-08-18 120 views
0

現在,我已經使用Google Maps iOS sdk爲我的室內地圖添加了地面覆蓋圖,可以使用代碼手動設置藍點(用戶當前位置)嗎?在室內設置當前位置 - Google Maps iOS SDK

我似乎無法找到一種方法來做到這一點。很高興看到一個示例代碼片段。

回答

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 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]; 


} 

這可能會有幫助。

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]; 
+0

謝謝,想象「檢測中心」每10秒鐘會改變一次,有沒有一種好的方法可以處理電池電量? – Gearbox

+0

使用您的應用程序行走或駕駛的人是? – gurmandeep

+0

只是走路而已 – Gearbox

相關問題