finding the nearest pharmacy on google maps

22,540

Solution 1

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.

Solution 2

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.

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

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

Solution 3

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 search or the Radar search

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

Solution 4

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.

Share:
22,540
dextererer
Author by

dextererer

Updated on October 01, 2020

Comments

  • dextererer
    dextererer over 3 years

    I am developing an application that finds the nearest pharmacy, hospital etc. on 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?

  • dextererer
    dextererer about 12 years
    yeah i see but is there any table or database that contains all pharmacies in the world??? i must find them dynamicly.Can google maps provides search by place name without knowing it's location before?
  • dextererer
    dextererer about 12 years
    Yeah i'm looking for something like that