2011-07-22 49 views
0

我有一組座標保存在數組中。我使用反向地理編碼如何給變量座標

我所用的方法,

- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate altitude:(CLLocationDistance)altitude horizontalAccuracy:(CLLocationAccuracy)hAccuracy verticalAccuracy:(CLLocationAccuracy)vAccuracy timestamp:(NSDate *)timestamp 

我需要轉換的緯度,經度CLLocationCoordinate2D。

self.atmLocation.latitude = [tempDict objectForKey:@"Latitude"]; //atmlocation is of type CLLocationCoordinate2D. 

這給了我一個錯誤「Expression is not assignable」。如何解決這個問題?如果這不可能比請建議任何其他方式,所以我可以使用外部座標集。

回答

0

tempDict返回一個對象。因此你需要轉換它。

嘗試self.atmLocation.latitude = [(NSString *)[tempDict objectForKey:@"Latitude"]doublevalue];

從文檔

typedef struct { 
    CLLocationDegrees latitude; 
    CLLocationDegrees longitude; 
} CLLocationCoordinate2D; 

typedef double CLLocationDegrees; 
+0

這仍然給了我同樣的錯誤。 – Harsh

+0

將代碼粘貼到創建atmLocation和tempDict的位置。 –

+0

您也可以將tempDict的返回類型轉換爲NSString,然後使用上面的方法。 –