简体   繁体   English

通过谷歌地图意图搜索附近的医院(Android)

[英]Search nearby hospital via google map intent (Android)

I need to search nearby child hospital and find the root from button click using intent, 我需要搜索附近的儿童医院,并使用意图从按钮点击找到根,

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
                        Uri.parse("http://maps.google.com/maps?&saddr="
                                + x
                                + ","
                                + y
                                + "&daddr=nearby child hospitals"

                                ));
                        startActivity(intent);

x,y as current lat and long. x,y为当前lat和long。

It will show the hospitals are not in my current location(Shows different country hospitals) Then, I click back button, then click Get Directions button means (From text box contains my source lat and long, Destinations text box contains nearby child hospitals), it shows my nearer child hospitals. 它会显示医院不在我当前的位置(显示不同的乡村医院)然后,我点击后退按钮,然后点击获取方向按钮意味着(从文本框中包含我的源lat和long,目的地文本框包含附近的儿童医院),它显示了我更近的儿童医院。

Is there any way do to this in first (ie, intent call)? 首先是否有任何方法(即意图调用)?

You can use "geo:" URL scheme to open maps and then search nearby hospitals like this: 您可以使用"geo:" URL方案打开地图,然后搜索附近的医院,如下所示:

String uri = "geo:"+ x + "," + y +"&q=child hospitals";
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));

For documentation reference, see Invoking Google Applications on Android Devices 有关文档参考,请参阅在Android设备上调用Google应用程序

you can use this code, intent open a map and automatic search hospital near me 你可以使用这个代码,意图打开一张地图并自动搜索我附近的医院

String uri = "geo:"+ x + "," + y +"?q=hospitals+near+me";
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));
 Uri gmmIntentUri = Uri.parse("geo:0,0?q=" + query);
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(gmmIntentUri.toString()));
        intent.setPackage("com.google.android.apps.maps");
        try {
            context.startActivity(intent);
        } catch (ActivityNotFoundException ex) {
            try {
                Intent unrestrictedIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(gmmIntentUri.toString()));
                context.startActivity(unrestrictedIntent);
            } catch (ActivityNotFoundException innerEx) {
                Toast.makeText(context, "Please install a maps application", Toast.LENGTH_LONG).show();
            }
        }

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

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