2016-01-27 36 views
2

當我在我的應用程序中點擊「在Google地圖中打開」按鈕時,我希望我的應用程序導航到Google地圖應用程序並打開我指定的地址並將標記到它。使用url方案將標記添加到ios中的google地圖

這裏是我爲此代碼:

UIAlertAction* googleMaps = [UIAlertAction actionWithTitle:NSLocalizedString(@"google_maps", @"Google Maps") style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { 
    NSString *customURL = @"comgooglemaps://?center=41.039400,28.994583&zoom=16&markers=size:mid%7Ccolor:0xff0000%7Clabel:1%7CVodafone+Arena+Stadyumu"; 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]]; 
}]; 

當我在按鈕上點擊,它正確地定位到特定的位置。但是,它並沒有給它一個標記。有沒有辦法做到這一點?

謝謝:)

回答

2

按照谷歌的文檔,在你的代碼中指定的格式錯誤: -

例子: -

comgooglemaps://?q=Vodafone+Arena+Stadyumu&center=41.039400,28.994583&zoom=15&views=transit 

這顯示的中心標誌地圖

+0

是的,這工作。謝謝 :) –

1

使用Google Maps URL Scheme的新格式,我們無法直接添加標記,但有一種解決方法,您可以將您的位置(lat-long和name)作爲se從URL和地圖的拱形查詢將顯示一個標記,因爲它顯示,而像這樣搜索 -

comgooglemaps://?q=Pizza&center=37.759748,-122.427135 
相關問題