简体   繁体   English

无法使用特定半径的Android在Google地图中找到地点

[英]Unable to find the place in google map using Android in specific radius

I want to find places of interest under a specific radius using Android. 我想使用Android在特定半径范围内找到名胜古迹。 I am working in this way 我以这种方式工作

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

But when I run the application, It opens the google maps but does not mark the child hospitals . 但是,当我运行该应用程序时,它会打开google地图,但不会标记child hospitals Any wrong here? 这里有什么问题吗?

Try this, 尝试这个,

Intent intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("geo:<40.007620>,<-75.160264>?q=<40.007620>,<-75.160264>(child hospitals)"));
        startActivity(intent);

Please check below reference which will guide you to how to pass or format map intent query data : 请检查以下参考,该参考将指导您如何传递或格式化地图意图查询数据:

https://developers.google.com/maps/documentation/android-api/intents https://developers.google.com/maps/documentation/android-api/intents

Example : 范例:

Uri gmmIntentUri = Uri.parse("geo:40.007620,-75.160264?q=" + Uri.encode("child hospitals"));

Humty you can try to this code hope this can help you.. 谦虚的您可以尝试这段代码,希望对您有所帮助。

Uri gmmIntentUri = Uri.parse("geo:40.007620,-75.160264?z=10&q=child hospitals");
            Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
            mapIntent.setPackage("com.google.android.apps.maps");
            startActivity(mapIntent);

You can try something like this : 您可以尝试这样的事情:

String urlAddress = 
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=lat,lng&radius=500&type=city hospital&keyword=hospital&key=YOUR_API_KEY

which you can pass to 你可以传递给

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlAddress);
startActivity(intent);

This will get opened in Google Maps with the results wrt provided radius. 这将在Google Maps中打开,并提供半径提供的结果。 It works also same mentioned in below doc reference. 它的工作方式也与下面的文档参考中提到的相同。

https://developers.google.com/places/web-service/search https://developers.google.com/places/web-service/search

Url to test : 要测试的网址:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=18.590478,73.727191&radius=50000&type=child%20hospital&keyword=child%20hospital&key=PASTE_YOUR_API_KEY https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=18.590478,73.727191&radius=50000&type=child%20hospital&keyword=child%20hospital&key=PASTE_YOUR_API_KEY

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

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