簡體   English   中英

打開谷歌地圖應用程序並在我自己的應用程序活動中顯示標記

[英]Open google maps app and show marker on it from my own apps activity

我試圖從我自己的應用程序活動中打開谷歌地圖應用程序。我想在地圖應用程序的特定位置顯示一個標記。到目前為止我發現的是這段代碼。

        String label = "shop";
        String uriBegin = "geo:" + lat + "," + lng;
        String query = lat + "," + lng + "(" + label + ")";
        String encodedQuery = Uri.encode(query);
        String uriString = uriBegin + "?q=" + encodedQuery + "&z=16";
        Uri uri = Uri.parse(uriString);
        Intent intent = new Intent(android.content.Intent.ACTION_VIEW,uri);
        startActivity(intent);

它的作用是打開地圖應用程序,但不斷向我顯示一個loading messageboxsearching for:<lat>,<lng>(shop)其中<lat> and <lng>是我提供的值。 這有什么不對嗎?

我從另一個stackoverflow帖子中復制了這段代碼。

更新您的谷歌地圖應用程序。

然后(如果還沒有工作),您可以嘗試使用以下代碼:

String uri = String.format(Locale.ENGLISH, "geo:%f,%f?z=17&q=%f,%f", latitude,longitude,latitude,longitude);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));

基於以下問題: 使用提供的位置和標記啟動Google地圖應用,以便標記顯示將查詢標記添加到URI

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM