Country restriction while using google place API nearby search - javascript

I'm creating a web application to search business organisations in an area. User will provide keyword and zip code for the search.
For searching, Place API Nearbysearch functionality is used. Latitude, longitude, radius and keyword are given for the request. I give radius of 10000. But while searching for businesses with a zip code of California, I got a business from Mexico also. I can't reduce the value of radius.
How can I get places only in the country of the zip code provided by the user?

It doesn't appear to be possible to filter Place results by country. None of the parameters for the API include a filter by geographic name.
https://developers.google.com/places/documentation/search#TextSearchRequests
What I would do is pull all results and filter results within your own code. The downside (besides your app doing more work and using more bandwidth) is that as you only get 20 results per page, you may have to pull multiple pages to get the desired number of results.

Related

Using google autocomplete places Javascript API can you bias results to a 'type' of location?

I am using the following API : https://developers.google.com/maps/documentation/javascript/places-autocomplete
I would like to restrict results as follows:
If a user has selected 'Airplane' - then the results should show only airports near the place typed by the user.
Likewise, if a user has selected 'Train' - then the results should show only train stations near the place typed by the user.
I don't see any documentation on that particular page suggesting this is possible. I have however elsewhere spotted a 'type' parameter which you can use....not sure how to work that here though.
Alternatively, I have thought - if the user selects 'Airport' I could always just append airport to their search query.
Any suggestions on the best way to do this?
According to the documentation, currently the types parameter of places autocomplete supports only following values:
geocode
address
establishment
(regions)
(cities)
https://developers.google.com/maps/documentation/javascript/places-autocomplete#add_autocomplete
There is a feature request in the public issue tracker to allow types mentioned in the http://code.google.com/apis/maps/documentation/places/supported_types.html in the places autocomplete.
Please take a look at this feature request:
https://issuetracker.google.com/issues/35820774
Feel free to star the feature request to add your vote.

Receive Google Autocomplete Results in Local Language

Google JavaScript API V3 allows to change the language in either English, German or French, but when I search for "Cologne" in English API it should return me "Köln", same as if I search for "Frankfurt" in French, it shall return me "Frankfurt" and not "Francfort". People might search all across Europe and I want to get the specific results in each of the resulted cities' local language. How is that possible?
When using Autocomplete service via the JavaScript API,the API detects the browser's setting for the end user and sets the language appropriately. Please see our doc for reference:
https://developers.google.com/maps/documentation/javascript/localization
That being said, if you don't include the language parameter when calling the JS API, the language will default to the setting in the end users' browser. This would most likely be the local language for that user.
I hope this helps!
There is a way to do this, at least partially.
Let me start by pointing out the premises:
The Maps APIs and Google Maps will be consistent in the following.
Names of political entities are shown in the user's preferred language.
Street-level addresses are shown in the local language, with a script friendly to the based on its preferred language.
With these in mind, you can do the following:
Once users selects a city (place_changed event is fired), take the
types and location latlng of the city.
Do a reverse geocode of the location latlng of the city.
Search for results with location_type other than "APPROXIMATE".
In those results, search for the address_component with the same types as the city. That will be the name of the city, in the local language.
Examples: get "Köln" for a French user:
User types "Cologne" and selects "Cologne, Allemagne".
City has latlng 50.937531,6.960279 and types: ["locality", "political"].
Reverse geocoding of 50.937531,6.960279 returns 2 results with location_type other than "APPROXIMATE".
From the first result, 4th address_component has types: ["locality", "political"]. It's name is "Köln".
Note that names are always in a script friendly to the user, so you get "Beijing" for a German user (instead of "北京") or "Tōkyō-to" instead of "東京都".

How can I find places close to given place list via google geocoding API

I have a list of doctors with addresses and zip codes and lat+lng,
I want to send my location (lat+lng) or zip and get all the near by doctors via google geocoding API
how can I do that?
Thank you.
You do not need to call any API for that. All you need to do is to calculate the distances between your location and doctors using a straightforward formula and make selection from the list based on that. If your data is stored in a database, most commercial databases offer spatial extensions which encapsulate distance calculations and support spatial indexes to speed up selections from large lists.

Does Google Maps API offer a way to search for locations by name?

When one visits http://maps.google.com, they are able to type queries into the search field and receive results based on locations or places, and not hard search results, as they would in a normal Google Search query. They're a unique style of result (names of places, locations) suited to the Maps interface for obvious reasons.
I've been digging through both the Maps and standard Google Search API for a couple hours now, and have done multiple searches on this question, and I can't seem to find the answer.
They obviously have the Local Search, but that's been deprecated, and it only yields results if you provide an initial lat/long. I want to be able to find places or locations with no initial lat/long.
Essentially what I want to do is allow a user to type in an address, name of a place or name of a city or state or a zip code, or essentially any other kind of location that is allowable on Maps, and geocode it. I feel stupid because this seems like it has to be there, but nothing I've seen in the API seems to do this.
I don't need the AJAX suggested results, necessarily. Just a way for a user to type in a nice name and geocode from it, though results as a user types would be ideal.
What am I missing here?
What you are looking is Geocoding API from google maps.
Find Documentation here
UPDATE 5/12/2011
Google just opened up public access to their Places API. This is more to the heart of the original question request:
https://developers.google.com/maps/documentation/places/web-service/autocomplete
I think you're looking for the google.maps.Geocoder class:
A service for converting between an address and a LatLng.

Use the Google Maps API to search within a predefined set of data

My client has a list of store locations. Now what he wants is to let users search for any of these locations, based on the address the user submitted. The search results will be based on the proximity of the locations.
So basically what I am looking for is Google Maps functionality, but based only on the set of (geographical) data I provide.
Do any of you know if this is even possible, and if so, what can be a good starting point to learn more about it?
Thanks in advance.
Sure it is possible. I guess you have in you database set of the latitude and longitude entries for each store. You can get users current location with geocoder and measure distance with distanceFrom call to find the nearest store.
You're welcome to copy the code directly from here, it does exactly what you request.
You'll need offices.htm, offices.js and logo.png.
To prepare your list of offices, you might find this Excel addin useful

Categories