0

I'm fairly new to app creation and definitely new to implementing google maps. Here is an outline of my project:

The user enters up to five places (restaurants) and hits a button to add them into a list. From the list, ignoring any blank textboxes, it pulls one of the list items, emulating random selection. The app also has a clear button that empties the list, textboxes, and the label designated to display the selection.

Here is where my issue begins. I want to use a button that will take the text from the selection and find the nearest location on google maps. For example, if, say, Burger King is selected, the button will open Maps and the nearest Burger King establishment would be displayed. As it stands, I'm currently not receiving the nearest location; I'm receiving locations that are hours away and, in some cases, out of state. I tried to use a location sensor to help come to a resolution, but to no avail. Perhaps I'm just missing something big or doing something incorrectly. Searching through the site and other sites have proven fruitless, as I receive either code answers to questions that don't quite pertain to my issue. I've found several on finding the user's location, finding places nearby, searching and storing coordinates, and Java, JavaScript, and Python code. Here is an image of the blocks I'm using.

Here are the blocks

enter image description here

Any help is sincerely appreciated.

Ivan Barayev
  • 2,035
  • 5
  • 24
  • 30

1 Answers1

0

You can use Place Types, the Google Places API Web Service allows you to query for place information on a variety of categories such as establishments, prominent points of interest, geographic locations and more. You can search for places either by proximity or a text string. A Place Search returns a list of places along with summary information about each place.

A Nearby Search lets you search for places within a specified area. You can refine your search request by supplying keywords or specifying the type of place you are searching for.

Request:

https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters

Include type parameter to restrict the results to places matching the specified type. Check the supported values for the types property in the Google Places API.

Response:

      "types" : [ "establishment" ],
      "url" : "http://maps.google.com/maps/place?cid=10281119596374313554",
      "vicinity" : "48 Pirrama Road, Pyrmont",
      "website" : "http://www.google.com.au/"
   },
   "status" : "OK"

Here's a related SO ticket, shows how to search nearby places: Getting results of nearby places from User's Location using Google Maps API in Android

Community
  • 1
  • 1
KENdi
  • 7,576
  • 2
  • 16
  • 31