Google Maps API Geocode Postal Code and set Country code? - api

I'm using this API call to Google Maps to get the latitude and longitude of a postal code
http://maps.googleapis.com/maps/api/geocode/json?address=2340&sensor=false
The postal code is in Australia. This API call returns locations all around the world with partial matching postal codes in the address.
Is there a parameter I can use to set the country to Australia?
Thanks

The correct way to do this is not via region biasing but rather using component filtering:
https://maps.google.com/maps/api/geocode/json
?components=country:AU|postal_code:2340
&sensor=false
Some demonstrations:
2340
93274
Please note that if you use the components parameter, you don't need to specify the address parameter.

The documentation says that Region Biasing is based on CcTLDs, which would make Australia au (haven't tried it myself).
Although it also states this:
Note that biasing only prefers results for a specific domain; if more relevant results exist outside of this domain, they may be included.

Related

Enforce MapBox Geocoding API to return only results with a zipcode

I'm working with MapBox Geocoding API to have suggestions of addresses in the location search feature of my website.
The following is a sample call:
https://api.mapbox.com/geocoding/v5/mapbox.places/Zur.json?country=ch&limit=5&proximity=8.765.432&language=en-GB&access_token=***
My goal is to enforce the api to return only results that include a zipcode.
For example if I input "Zur" (limiting the search to Swiss) I get the following:
- Zürich, Zürich, Switzerland
- Zürich, Switzerland
- Zürich Airport, Flughafenstrasse, Kloten, Zürich 8302, Switzerland
- Zurich, Buchs, Zürich 8107, Switzerland
The expected results should be without the first two lines, as they don't have a zipcode.
I tried implementing myself the removal of results without the zipcode on client side (just after I got an answer from the api), but it is a suboptimal solution (for example it doesn't ensure to have enough results).
I was not able to find such feature in MapBox. Is there a better solution out of there?
Just add ?types=address
See all list of types:
https://docs.mapbox.com/api/search/geocoding/#data-types

Issue with google geocode API : Getting "partial_match" in response

I am using google Geocode API to get the lat long of particular address.
when I am searching for "364 S Side Square, Carlinville, IL 62626, USA" in google search or google maps it gives the accurate pin point on google search result or maps result.
but same time when i am searching the same address using Geocode API using below request call, it gives "partial_match" : true
http://maps.googleapis.com/maps/api/geocode/json?address=364 S Side Square, Carlinville, IL 62626, USA&sensor=false
any one knows why it gives "partial_match" : true in response ?
what changes i have to do in the API request so that i won't get "partial_match" ?
To understand the nature of the partial match flag for the '364 S Side Square, Carlinville, IL 62626, USA' let's have a look at this address in geocoder tool:
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3D364%2520S%2520Side%2520Square%252C%2520Carlinville%252C%2520IL%252062626%252C%2520USA
Indeed, the search string and formatted address in the result are exactly the same, however, we have to pay attention to other values like location_type and place_id
As you can see the location type is RANGE_INTERPOLATED and the place ID has a long value Ei0zNjQgUyBTaWRlIFNxdWFyZSwgQ2FybGludmlsbGUsIElMIDYyNjI2LCBVU0E. This means Google doesn't have an exact address feature in their database and tries to interpolate where this address might be located. In case if address exists in the Google database, you will see a location type ROOFTOP and a shorter place ID (something similar to ChIJrTLr-GyuEmsRBfy61i59si0).
Resuming aforementioned, the partial match flag in your example indicates that exact street address feature doesn't exist in the Google database.
This also can be confirmed by the following sentence in the documentation:
Partial matches most often occur for street addresses that do not exist within the locality you pass in the request.
https://developers.google.com/maps/documentation/geocoding/intro#GeocodingResponses
You also have an option to report a missing address to Google following the help center:
https://support.google.com/maps/answer/6320846
I hope my answer addresses your doubt!
partial_match indicates that the geocoder did not return an exact match for the original request, though it was able to match part of the requested address. You may wish to examine the original request for misspellings and/or an incomplete address.
Partial matches most often occur for street addresses that do not exist within the locality you pass in the request. Partial matches may also be returned when a request matches two or more locations in the same locality. For example, "21 Henr St, Bristol, UK" will return a partial match for both Henry Street and Henrietta Street. Note that if a request includes a misspelled address component, the geocoding service may suggest an alternative address. Suggestions triggered in this way will also be marked as a partial match.
try place_id which is unique identifier

Google Api geocoding with postal code

i'm trying to use the API Google to have latitude and longitude from an address and a postal code.
I tried to use it :
https://maps.googleapis.com/maps/api/geocode/json?sensor=false&region=fr&address=MYADDRESS&postal_code=13002
But when i see the results, i can see that i've result with different postal code.. why ?
ok i found my error :
&components=postal_code:13002, instead of postal_code=13002

Foursquare API Venue search, restrict by country and zip code

I am able to restrict venue search to either a country or zip code, but not both.
I am aware the following example is not possible, but what I am trying to achieve is something like this:
https://api.foursquare.com/v2/venues/search?near=COUNTRYCODE&near=ZIPCODE
How can I do this?
You should be able to pass in "[Postal Code], [countrycode]" as a single string into the near parameter and that should work

FourSquare API is giving lots of result but not the result I expect

I am using FourSquare api for searching a particular business
https://api.foursquare.com/v2/users/search?name=Spa Gregories&oauth_token=ACCESS_TOKEN
it is giving lots of result but not the result i expect. that is
Spa Gregories
2710 Via De La Valle, Ste B-270
San Diego, California 92014
when i use https://foursquare.com/search?q=Spa+Gregories&near=san+diago then i got the exact result. So is their any way to find the business according the location. I have only name and city location to use for Search. I have also checked for the venues option but it asks for longitude and latitude.
thnks
Seems you're hitting the user search endpoint instead of the venue search.
Looks like this is the one you want:
https://developer.foursquare.com/docs/venues/search.html