Receive Google Autocomplete Results in Local Language - javascript

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 "東京都".

Related

Azure maps Fuzzy search: when I search on azure maps I want postal codes to be autocompleted

I am creating an autocomplete widget using jQuery and ajax, and some queries will be in the form of zip codes. When the user types in less than 5 digits of their postal code, I want azure maps to return a fuzzy search like they would if I types in a partial city name. '5393' should return results with the various Wisconsin cities under those numbers even though it is incomplete.
here is my current key:
https://atlas.microsoft.com/search/fuzzy/json?subscription-key={key}&api-version=1.0&query={query}&typeahead=True&countrySet=US&view=Auto&entityType=PostalCodeArea&limit=20
I have already looked through the documentation extensively, so if you could point my to a parameter or something else I can do to have this happen I would greatly appreciate it
Try using the address service rather than the fuzzy search service. The fuzzy search service favors addresses and full addresses. With the address service you can limit the result entity type. Try adding &entityType=PostalCodeArea. If this doesn't work, try using the V2 search geocoding service, that is a lot more flexible by the looks of things.

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.

Google geocode location result differs from maps result

I have a address in Germany
Deutschland, 13086 Berlin, Caligariplatz 1
If I search for "Caligariplatz 1" directly in maps it shows the right location.
[https://www.google.de/maps/place/Brotfabrik/#52.552605,13.430414,17z][1]
If I use the geocode function from the api
[https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=13086%20Berlin,%20Caligariplatz%201][2]
The formatted address in the result is 13086 Berlin, Deutschland without the street. The location is wrong. The location_type is only APPROXIMATE
Is it possible that some streets are not known by the geocode Database?
It's not the only problem. How can i fix it?
A couple of things first:
The geocoder is not a general purpose map/location search. It specifically tries to determine a position for an address. It is therefore inherently different to a search on Google Maps, which for example also supports searches like "parks in Berlin". Also, the data used by the Geocoder might be different.
Addresses should be formatted according to the conventions of the local postal service. Your address should be formatted "Caligariplatz 1, 13086 Berlin"
Now for your particular address, Google Maps finds it because there is a Place with that address. You could actually find this location with the Places API.
The address itself does not appear to be in the database, as you can for example confirm with MapMaker. Since this is a square and not a traditional street, the building in question should probably be edited to include the address.

Country restriction while using google place API nearby search

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.

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.

Categories