繁体   English   中英

结合使用InMapClickListener和意图活动

[英]Using OnMapClickListener with intent activity

我的Android应用程序在我的第一个活动中正在调用Google Maps(使用ACTION_VIEW)。

public void goToMap(View v)
{
    Toast.makeText(this,"Button is clicked",Toast.LENGTH_SHORT).show();
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("geo:23.214889,77.3988962"));
    intent.putExtra("Id", "map");
    startActivity(intent);
}

没有在任何地方指定将GoogleMap对象与OnMapClickListener一起使用的文档。

我正在尝试的是:

@Override
public boolean onCreateOptionsMenu(Menu menu) 
{
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);

    GoogleMap map;

    // Here--------------------------------------------
    // What object should this map object be and how should i use this.
    map.setOnMapClickListener(new OnMapClickListener() {

        @Override
        public void onMapClick(LatLng point) {
            // TODO Auto-generated method stub
            double lat = point.latitude;
            double lng = point.longitude;
        }
    });

    return true;
}

我尚未为要开始的意图分配ID。

我想对我的GOOGLE MAP TOUCH EVENT使用onMapClick()函数。 如何初始化地图对象,使其可以用于Click Listener事件。

请指导我。

谢谢。

您应该调用getMapAsync方法。 像这样:

mapFragment.getMapAsync(this);

接着:

@Override
public void onMapReady(final GoogleMap map) {
    this.map = map;
    //Set On Map Click Listener here
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM