由街道名称在地图上显示有关磋商的位置 [英] Consultation about show location on map by street name

查看:136
本文介绍了由街道名称在地图上显示有关磋商的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能在地图上按街道名称使用的Andr​​oid和Java显示地点?

How i can show location on map by street name using android and java ?

例如:我会请在我的程序街,城市 - 和我得到在地图上的位置

For example: i'll type in my program street,city - and i get the location on map

我有这样的例子:

Intent i = new
        Intent(android.content.Intent.ACTION_VIEW,
        Uri.parse("geo:31.06221,33.781642"));
        startActivity(i);

如何改变这种code插入街道和城市?我尝试这个办法:

how to change this code for inserting street and city ? i try this:

是这样的: Uri.parse(地理:帝国大厦));

但它不工作):

推荐答案

使用反向地理编码与地理codeR

例为实现帝国大厦的坐标:

Example for achieving coordinates of Empire State Building:

Geocoder geoCoder = new Geocoder(this, Locale.getDefault());    
        try {
            List<Address> addresses = geoCoder.getFromLocationName(
                "empire state building", 5);
            String add = "";
            if (addresses.size() > 0) {
                String coords = "geo:" + String.valueOf(addresses.get(0).getLatitude()) + "," + String.valueOf(addresses.get(0).getLongitude());
                Intent i = new
                      Intent(android.content.Intent.ACTION_VIEW,
                             Uri.parse(coords));
                startActivity(i);
            }  
    } catch (IOException e) {

            e.printStackTrace();
        }

这篇关于由街道名称在地图上显示有关磋商的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆