2011-08-11 51 views
0

在我的應用程序中,我能夠獲取我當前位置的座標。但谷歌的地方串像將位置座標傳遞到谷歌地方查詢字符串

"https://maps.googleapis.com/maps/api/place/search/xml?location=52.577798767,-2.124885567&radius=500&types=bank&sensor=false&key=AIzaSyCcC9pmri9XGOgydfsaadq37cmcb6fsd80" 

現在我怎樣才能把我的動態座標(如果我改變我的位置我的座標將是新的),而不是固定座標?

我想在

NSURL *googlePlacesURL = [NSURL URLWithString:googleUrl]; 

NSData *xmlData = [NSData dataWithContentsOfURL:googlePlacesURL]; 

a和b使用此字符串是

a = [NSString stringWithFormat:@"LATITUDE: %f", location.coordinate.latitude]; 
//b = [NSString stringWithFormat:@"LONGITUDE: %f", location.coordinate.longitude]; 

回答

1
NSString *urlString = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/xml?location=%f,%f&radius=500&types=bank&sensor=false&key=AIzaSyCcC9pmri9XGOgydfsaadq37cmcb6fsd80", longAsFloat, latAsFloat]; 

這可能是很難看到的,但我在的地方添加 「%F」你的長和拉,這將允許你將它們傳遞到字符串中。然後,您可以使用新的自定義字符串構建網址。希望這可以幫助。