Google places API doesn't return postal codes for large cities or centres. How do I get around that? - google-places-api

I'm utilising google autocomplete to allow visitors to enter towns, suburbs or postcodes, so that they can select the right one from the autocomplete list. I then need to store the postcode for that location so that I can compare that postcode to entries in a database to find service providers in that postcode.
The problem I'm now having is that the Google API doesn't return postcodes for all locations. This especially seems to be the case for larger cities. For example, it doesn't return postcodes for Melbourne Australia, Sydney Australia or Perth Australia.
Has anyone developed a solution or workaround to this issue? Any suggestions?
I've been googling for ages now and can't find a solution. Google itself doesn't seem to mention this situation in their Google Places docs.

Since many cities span multiple postal codes, you probably need your users to provide the exact street address where they need service. Fearing the tedium of entering a full street address? Fear not; Place Autocomplete can save them many keystrokes especially if you constrain results to a specific country or location bounds.
You might want to create an address form and use Places Autocomplete to auto-fill the components including postal code once the user selects the address from autocomplete predictions. This section of the documentation demonstrates how it works and this page provides sample Javascript code for implementing an auto-completing address form.

Related

Store Google Places "place_id" and refresh them

I've just spent a long time reading documentation about the Google API Places, and there's some information I don't quite understand.
I need to build an application that can record a travel plan for a user, so a sequence of places.
For this, I need a very simple form, with a "destination" input, which will use "Autocomplete Places".
This endpoint return a place_id for the selected location, which is the only thing I'm allowed to store in a database, according to Google's terms and conditions.
So in my idea, I'll store this id, and a itinerary would be made of a sequence of place_id, without the need to store the place name or anything else. To display the user's itinerary, I'd just have to make Place Details queries, with the identifier.
But the documentation specifies that these ids can change over time, so they advise to redo queries "periodically" to refresh the place_id.
But how can I redo queries if I haven't stored any information about the place, other than the place_id ? Do I need to store the name of the place (and do I have the right to do that?) to be able to retrieve its ID, or am I missing something?
Another thing: I didn't find, or didn't understand, in the terms of use, if I was allowed to store data generated by my site beside Google IDs, for example, to store comments about places.
Sorry if I make language mistakes, im not fluent in english.
Thanks !

Where to find all possibilities to address_components types?

I need to deal with all that comes from Google Places API and save in a MySQL database.
With that purpose, I need to know all address components types because they will be column in my address table, but after look at documentation and tried to google it, I didn't find a thing.
Is there this information somewhere?
In Documentation example there are those types:
floor
street_number
route
locality
political
administrative_area_level_2
administrative_area_level_1
country
postal_code
But when I request the API with other address, those types change. Example:
postal_code
route
political
sublocality
sublocality_level_1
administrative_area_level_2
administrative_area_level_1
country
I found it, it was at intro, not in Google Place Search or Google Place Detail section:
https://developers.google.com/maps/documentation/geocoding/intro#Types
Looks like this was moved again:
https://developers.google.com/maps/documentation/geocoding/requests-geocoding#Types

Google Places API Attributes

I'm trying to determine if the Google Places API is suitable for a restaurant review website I'm working on (disclaimer: I'm not a developer so please excuse my lack of knowledge here).
Specifically, looking at https://developers.google.com/places/documentation/details for support, I'm trying to determine if the Places API includes the following restaurant-specific attributes in its database that we could query: cuisine type (i.e. Indian, Brunch, American) and/or neighborhood (i.e. Marina, Mission, Financial District). As an example in Layman's terms, if we were to use the Google Places API, would users on our site be able to search for Indian restaurants in the Financial District and see restaurants that meet that criteria?
Thanks,
Jaydon
You'd have to make a search using the 'type' restaurant and enter in the search the term indian, as for the location you could use a radius
In layman's terms yes you can, but the neighborhood would be determinated from one central location in a radius format (wouldn't fallow the specific outline of the actual neighborhood) and the type of food would have to be included in the search terms, you could automatically add that, in other words, you can ask the end user to specify the cuisine he is looking for (multi choice) that way you add that cuisine automatically within the search terms.

Finding product name from UPC/EAN

Is there any way to get the product name from UPC/EAN barcode scanned from Google API?
There is no general registry of UPC product codes. You can find a list of the country codes at the beginning of the number easily, and with some legwork possibly get the national organization for a few countries that you're particularly interested in to give you a list of their secondary allocations.
But in order to get all the way down to "Banana chips, bag of 200 g, reduced trans fat formulation, Danish/Swedish/Finnish text on packaging" there's only the particular manufacturer to ask. That, or own a supermarket and register the UPC numbers of new items when you start stocking them.
Allegedly the gtin field holds the UPC/EAN code, if you restrict the search to values in that field you should only get responses where the gtin matches your barcode.
For example if you scanned your barcode and got an EAN-8 code of 05001234 then in the query string of your API call you could set
https://www.google.com/search&q=05001234&restrictBy=gtin=05001234
I have often seen multiple products returned for a single code so I guess the UPC/EAN are not globally unique or some providers have not been uploading their products under the right code.
In the response from Google are fields which hold the product title and description, you just need to parse the JSON or ATOM response.
I found another API https://market.mashape.com/mignify/gtin2product. It's pretty good. You can get products information from UPC/EAN/GTIN. It can return products description in different language.
You can use Rapid API https://rapidapi.com/search/ean. Here you get lot of API like Amazon API, Google Shopping, Barcode Lookup

Best way to implement users location that allows me to see what users live roughly in the same area

A key part of my current project is users having the ability to see what other users live near to them. What is the best way to implement this?
I would just ask for country, state and city but because this will be international I can't have a fixed drop down list of states/administrative regions for each country, so if users spell the name of their state differently this will hinder my ability to detect that users live in the same state.
Say for example we have an the Swiss canton "St. Gallen". Some user will spell that as "Saint Gallen", others as "St Gallen" and so on. Which is obviously problematic.
Could I just ask for the zip code and use that? I've found some zipcode tools online but I'm suspecting they don't work very well. Has anyone used them?
Thanks for your asnwers.
Shouldn't you base your query on geographical data rather than administration one? I mean instead of comparing cities/zip codes just find people within, let's say, 5 km from current user location. And if you let every user to choose his/her location on the map, this will be as simple as choosing it from a series of drop-down lists or entering a ZIP code. Also there is an emerging geolocation HTML feature.
Querying such an information is different story thou. You'll probably gonna have to use GIS capabilities of your database: MySQL, PostgreSQL, Oracle and others.

Resources