2016-12-13 49 views
1

我的問題與此問題非常相似(Android - How to launch Google map intent in android app with certain location, zoom level and marker),但接受的答案對我無效。它會在正確的地點和正確的縮放級別打開地圖,然後繼續放大到街道級別的視圖(zoom = 16或17?)。Android - 如何在Android應用程序中啓動Google地圖意圖設置縮放級別和標記

我已經搜索過,我已經通過this文檔閱讀,但找不到地點標記組合&縮放,做我所需要的。

我試圖使用谷歌地圖的版本 8.2.0, 9.20.1幾臺設備, 9.36.2 & 9.42.3

這裏是日誌打印的結果(烏里用於意圖) 地理:39.29038619995117,-76.61219024658203 q = 39.29038619995117%2C-76.61219024658203(巴爾的摩)& Z = 11

從其他職位的答案是4歲了吧?。地圖改變了,這樣現在不起作用了嗎?另一個答案是否只工作,因爲他們將縮放設置爲17,並沒有注意到它不會解決另一個縮放級別?我錯過了別的嗎?

要清楚地說明我的問題: 如何使用地理意圖打開地圖應用程序以顯示地點標記並同時選擇縮放級別?

我的代碼基於從其他帖子接受的答案。

double latitude = item.getLatitude(); 
double longitude = item.getLongitude(); 
String label = item.getName(); 
String uriBegin = "geo:" + latitude + "," + longitude; 
String query = latitude + "," + longitude + "(" + label + ")"; 
String encodedQuery = Uri.encode(query); 
String uriString = uriBegin + "?q=" + encodedQuery + "&z=11"; 
mListener.onListFragmentInteraction(uriString); 

然後

public void onListFragmentInteraction(String url) { 
    Uri geoLocation = Uri.parse(url); 
    Log.d(TAG, "geo uri = " + geoLocation); 
    Intent intent = new Intent(Intent.ACTION_VIEW); 
    intent.setData(geoLocation); 
    startActivity(intent); 
} 
+1

此功能在Google地圖7.x後中斷。 –

+0

請參考:https://developer.android.com/guide/components/intents-common.html#Maps –

+0

@HarjotSinghOberai「在7.x之後破解」。謝謝,我很害怕這個。你知道這是故意還是有機會修復?你知道任何可以涵蓋這一變化的文件嗎? – Gary99

回答

0
Uri gmmIntentUri = Uri.parse("geo:37.7749,-122.4194?z=10&q=restaurants") 

意圖mapIntent =新意圖(Intent.ACTION_VIEW,gmmIntentUri) mapIntent.setPackage( 「com.google.android.apps.maps」) startActivity( mapIntent)

+0

我在文檔中看到它時忽略了這一點。我只是試圖確定,但我對餐館並不感興趣。感謝這次嘗試,但這不是我正在尋找的。 – Gary99

+0

@ Gary99刪除餐廳ü必須添加隱藏地圖功能內容在這裏是鏈接: – user1782565

相關問題