第三方应用如何调用google maps导航或显示某个区域的地图

来源:互联网 发布:解释型编程语言 编辑:程序博客网 时间:2024/05/17 09:02

方法: 使用Intent来启动google maps

参数:

1. 导航:

    Action: Intent.ACTION_VIEW

    Uri: http://maps.google.com/maps?saddr=xxx&daddr=yyy       

    其中xxx表示导航起点,yyy表示导航终点。如果导航起点是当前地点,那么可以去掉saddr这个参数及其设置,也就是修改为:

    http://maps.google.com/maps?daddr=yyy

    示例代码:

Intent intent = new Intent();intent.setAction(Intent.ACTION_VIEW);// 从当前地点导航到Las VegasUri uri = Uri.parse("http://maps.google.com/maps?daddr=Las Vegas");// 从Boston导航到Las Vegas// Uri uri = Uri.parse("http://maps.google.com/maps?daddr=Las Vegas");// 也可以这样用:导航到Las Vegas// Uri uri = Uri.parse("google.navigation:q=" + mResultQuery);intent.setData(uri);startActivity(intent);


2. 查询地图上面的某个地方的地图:

    Action: Intent.ACTION_VIEW

    Uri: http://maps.google.com/maps?q=xxx

Intent intent = new Intent();intent.setAction(Intent.ACTION_VIEW);// 从当前地点导航到Las VegasUri uri = Uri.parse("http://maps.google.com/maps?q=Las Vegas");intent.setData(uri);startActivity(intent);


0 0
原创粉丝点击