[英]Search nearby hospital via google map intent (Android)
我需要搜索附近的儿童医院,并使用意图从按钮点击找到根,
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为当前lat和long。
它会显示医院不在我当前的位置(显示不同的乡村医院)然后,我点击后退按钮,然后点击获取方向按钮意味着(从文本框中包含我的源lat和long,目的地文本框包含附近的儿童医院),它显示了我更近的儿童医院。
首先是否有任何方法(即意图调用)?
您可以使用"geo:"
URL方案打开地图,然后搜索附近的医院,如下所示:
String uri = "geo:"+ x + "," + y +"&q=child hospitals";
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));
有关文档参考,请参阅在Android设备上调用Google应用程序
你可以使用这个代码,意图打开一张地图并自动搜索我附近的医院
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.