Android 在谷歌地图上找到最近的药房

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10243822/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:59:47  来源:igfitidea点击:

finding the nearest pharmacy on google maps

androidgoogle-mapslocation

提问by dextererer

I am developing an application that finds the nearest pharmacy, hospital etc. on Android.

我正在开发一个应用程序,可以在 Android 上找到最近的药房、医院等。

I can get my location details on the phone but how I can find places near by me? Can google maps provide a search on mapview by place name?

我可以在电话上获取我的位置详细信息,但如何找到我附近的地点?谷歌地图可以通过地名在地图视图上提供搜索吗?

回答by erbsman

This would be one way to do a search for the word Pharmacy

这将是搜索“药房”一词的一种方法

String url = "http://maps.google.co.uk/maps?q=Pharmacy&hl=en"
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(url));      intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
startActivity(intent);

And you could look at maps.google.com for more details on how to define the bounding box for your search.

您可以查看 maps.google.com,了解有关如何为搜索定义边界框的更多详细信息。

回答by racingWild

Best way to do this would have a list of the pharmacies in a database. Maybe local or on a server and when querying the database use the following query which finds the closest pharmacies to your location using the harvesine formula.

最好的方法是在数据库中列出药房。可能在本地或在服务器上,在查询数据库时使用以下查询,该查询使用 harvesine 公式查找离您所在位置最近的药房。

SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;

https://developers.google.com/maps/articles/phpsqlsearch

https://developers.google.com/maps/articles/phpsqlsearch

The tutorial above is not aimed at android but it is a good tutorial to understand how to find to closest locations to a user, I have developed something similar to yourself and found that tutorial very helpful

上面的教程不是针对 android 的,但它是一个很好的教程,可以了解如何找到离用户最近的位置,我开发了类似于你自己的东西,发现该教程非常有帮助

回答by daegren

Take a look at the Google Places API, it allows you to search for places around a given location (lat,long) through some easy REST endpoints, the one you're probably looking for is the Near me searchor the Radar search

看看 Google Places API,它允许您通过一些简单的 REST 端点搜索给定位置(纬度、经度)周围的地方,您可能正在寻找的是Near me 搜索Radar 搜索

https://developers.google.com/places/documentation/

https://developers.google.com/places/documentation/

回答by Neha

I had develop the same kind of application which finds nearest ATM Machine for. The logic is very simple , you need to first store all phamesy's lat-lon in a table and now find the nearest distance by calculating with the current lat-lon detail.

我开发了相同类型的应用程序,可以找到最近的 ATM 机。逻辑很简单,你需要首先将所有phamesy的纬度存储在一个表中,然后通过计算当前纬度细节来找到最近的距离。