0

私はこれを1週間以上続けています。アプリでGoogleマップアクティビティを設定しようとしましたが、うまくいきませんでした。また、アプリケーションからGoogleマップアプリを呼び出すことができるようです。Onclicklistenerを使用する。ボタンを使用してアプリからGoogleマップアプリを開くにはどうすればよいですか?これは私が使用しているコードです...

import com.google.android.maps.GeoPoint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Store10 extends Activity {

    Context context;
    GeoPoint geo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.store10);

        Button num10 = (Button) findViewById(R.id.pNumber10);
        Button nav10 = (Button) findViewById(R.id.Map10);

        num10.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                // TODO Auto-generated method stub
                Intent myIntent = new Intent(view.getContext() ,Num10.class);
                startActivityForResult(myIntent, 0);
            }
        });
        nav10.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                // TODO Auto-generated method stub
                String uri = String.format("geo:%f,%f",40,325874,76,002211);
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                context.startActivity(intent);
            }
        });
    }

}

これが私が設定しようとしているOnclicklistenerです

nav10.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                // TODO Auto-generated method stub
                String uri = String.format("geo:%f,%f",40,325874,76,002211);
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                context.startActivity(intent);
            }
        });
4

5 に答える 5

5

これらのコード行を試すことができます...

String uri = "http://maps.google.com/maps?saddr=" + "9982878"+","+"76285774"+"&daddr="+"9992084"+","+"76286455";
            Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
            intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
            startActivity(intent);  
于 2012-05-03T09:50:55.747 に答える
3

URIを変更してズームレベルを設定します

uri = Uri.parse("geo:37.827500,-122.481670"?z=10"); 

マーカーを追加するには、これを試してください。

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<lat>,<long>?q=<lat>,<long>(Label+Name)"));
startActivity(intent);

ラベルが必要ない場合は、(Label + Name)を省略できます。ラベルは、最寄りの通りなど、関連性があると思われるものに基づいてランダムに選択されます。

于 2012-05-03T07:37:56.553 に答える
3

これは私がそれをした方法です...

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(
"geo:"    + marker.getPosition().latitude +
","       + marker.getPosition().longitude +
"?q="     + marker.getPosition().latitude +
","       + marker.getPosition().longitude +                                   
"("       + marker.getTitle() + ")"));

intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
于 2013-09-24T15:15:18.040 に答える
2

//---[地図を表示]ボタン---

 b3 = (Button) findViewById(R.id.btn_showMap);
 b3.setOnClickListener(new OnClickListener()
 {
 public void onClick(View arg0){
 Intent i = new
 Intent(android.content.Intent.ACTION_VIEW,
 Uri.parse("geo:37.827500,-122.481670"));
 startActivity(i);
 }
 });
于 2012-05-03T07:14:10.693 に答える
1

こちらのURLを確認してください。

Uri uri = Uri.parse("geo:13.070984,80.253639");
Intent in = new Intent(Intent.ACTION_VIEW, uri);
startActivity(in);
于 2012-05-03T07:21:39.400 に答える