Response from geocoding API - google-maps-api-3

I'm able to get the fully formatted address from the api,
"1600 Amphitheatre Parkway, Mountain View, CA 94043, USA"
for example.
How do i "breaking to pieces" this formatted address(city, street, country etc)?
code for getting the fully address -
final formattedAddress =decodedResponse['results'][0]['formatted_address']

According to the result from the api(https://developers.google.com/maps/documentation/geocoding/intro#GeocodingResponses)
I can write decodedResponse['results'][0]['address_components'][0]['long_name']
The second [0] indicate the location of the type

Related

Empty Results from Here API for the sample zipcodes

When I do the GET Request to the here API with the below zip codes I am getting an empty list. But When I google these zip codes, I can see that they are valid.
Here is the GET Request URL: https://geocode.search.hereapi.com/v1/geocode?qq=postalCode=[Insert-zip-code];country=USA&apiKey=[Insert-API-Key]
Below are the fallowing Zip Codes:
75046
34988
68902
45258
19486
88102
32245
28603
68501
93403
68602
91365
Try with https://geocode.search.hereapi.com/v1/geocode?q=postalCode=zip_code+USA&apiKey=your_api_key
Notice that there is only one q.
The above will work, but in some cases it will give you results not only from the United States.
Keep in mind what the API documentation says for this service:
Address lookup by postal code (SGP, IRL)
(...) This feature is available for these two countries only.
It's only for Ireland and Singapore.
There is an alternative for the United States (and Netherlands), but it requires the zip+4 code.
What is a Zip+4 Code?
A ZIP+4 code uses the basic five-digit code plus four additional
digits to identify a geographic segment within the five-digit delivery
area, such as a city block, a group of apartments, an individual
high-volume receiver of mail, a post office box, or a specific
delivery route
Example: https://geocode.search.hereapi.com/v1/geocode?qq=postalCode=60606-1506&apiKey=your_api_key
Notice that there are two q's.

Encountered problem with geocoder Here API for searching island

I'm using https://geocoder.api.here.com/6.2/search.json, and when I make a search for "Ile de Ré, France" I have a response but in the object Address I have this :
Address: {Label: "D735, 17000 La Rochelle, France", Country: "FRA", State: "Nouvelle-Aquitaine",…}
Label: "D735, 17000 La Rochelle, France"
Country: "FRA"
State: "Nouvelle-Aquitaine"
County: "Charente-Maritime"
City: "La Rochelle"
Street: "D735"
PostalCode: "17000"
Instead of having the all island...
Does someone know how to have the all island address instead of just having a road?
This is the resquest :
https://geocoder.api.here.com/6.2/search.json?language=fr&app_id={APPID}&app_code={APPCODE}&searchtext=%C3%8Ele%20de%20R%C3%A9&additionaldata=IncludeShapeLevel%2C%20default&gen=9&mapview=46.14288%2C-1.5629%3B46.2582%2C-1.25416
Thanks ! =)
It is not entirely clear from your question what your expected response is. If you are expecting a list of all addresses in the area, that is not supported.
If you are expecting to get the shape/area of the island as a polygon, then you need to use the mode "retrieveAreas" as Michael has stated above. This blog post on How to Get the Shape of an Area using the HERE Geocoder should hopefully answer most of your questions regarding this feature.
The API call you are looking for would be the following, which retrieves the postal code area around a location. Note that in order to get the location as a lat/long you need to first Geocoder "Ile de Ré, France" using the forward Geocoder.
https://reverse.geocoder.ls.hereapi.com/6.2/reversegeocode.json
?apiKey=YOUR_API_KEY
&prox=46.20054,-1.39985
&mode=retrieveAreas
&additionaldata=IncludeShapeLevel,postalCode
However, the Geocoder can only retrieve areas such as postal codes, administrative districts, counties, etc. In this case, none of them correspond exactly to the island. For example the island has multiple postal codes and its county covers a much larger area.
You can use this code example I've built to experiment. Here's a screenshot made using this tool to show the area of a postal code on the island.
Try adding mode=retrieveAreas to your API call

What are address26 and address29 in Nominatim?

Occasionally - rarely - a Nominatim search will return a hit with a key "address29" or "address26". There is no mention of such a key in osm, and I can't find any explanation in Nominatim.
Here's an example. Search nominatim for bamako (the capital city of Mali). Among others you'll see:
{"place_id":"104544188","licence":"Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright",
"osm_type":"way","osm_id":"197528638","boundingbox":["47.4519905","47.4523668","-0.5565341","-0.5561207"],"lat":"47.4519905","lon":"-0.5565341",
"display_name":"Bamako, Angers, Maine-et-Loire, Pays de la Loire, Metropolitan France, 49000;49100, France",
"class":"highway","type":"platform","importance":0.2,
"address":{"address26":"Bamako","city":"Angers","county":"Angers","state":"Pays de la Loire","country":"France","postcode":"49000;49100","country_code":"fr"},"namedetails":{"name":"Bamako"}},
In the address field/object you see "address26":"Bamako". What does that mean? the other keys all make sense.
If you access the osm id: (eg, http://nominatim.openstreetmap.org/details?osmtype=W&osmid=197528638), there is no mention of address26.
At the website: https://thefive.sabic.uberspace.de/ they have a number of address26 entries pointing to Nominatim. I don't know what their database represents.
I have come across other Nominatim search results with address29 instead of address26.
If you look at http://taginfo.openstreetmap.org/, you won't find address26 or address29 as keys or tags...
Once in a while you will see a city named "fixme" on an osm map, but at least you have an idea of what's going on there, address2[69] stumps me. Does anyone know why?

language parameter with here geocoding

i am using the here geocoding and map tiles services.
geocoding search for oran, algeria returns address information in arabic. map tiles for oran, algeria show address information in french. here.com map site for oran, algeria also shows address information in french. i would prefer geocoding information in english. when making my geocoding request i have added "&language=en". information returned in arabic. i have also tried a request but with "&language=fr". information returned in arabic. is it possible to have geocoding information returned in english? and, out of curiosity, since here seems to have the information in french when generating its tiles, is it possible to have geocoding information returned in french?
i notice that for, eg, tokyo, japan, the information is returned in english (or a sort of trans-literated englsh), not japanese. the same is true for, eg, moscow, russia. map information is in english, not cyrillic characters.
the only rule or guidance that i have found in the here documentation regarding language parameters concerns using a language list (&languages= ...)
thanks for any help.
- george ott
When geocoding an address, the language parameter will only alter the exonym for the city and country. Take for example the Grote Markt/Grand Place in the center of Brussels.
If you search for Grand Place - the address is in French
If you search for Grand Place with language=en - the address is in French, the city and country are in English
If you search for Grote Markt - the address is in Dutch
If you search for Grote Markt with language=en - the address is in Dutch, the city and country are in English
If you want to obtain the Dutch name for the French street, you will need to make two requests - firstly a geocoding request to find out the longitude/latitude and then a reverse-geocoding request to find out the local name of a location in the language of your choice.
For example Rue Bouzerki Mohamed/ نهج بوزركي محمد, وهران, الجزائر is a street in Oran:
Geocode the Arabic text to a location like this
Reverse Geocode to get the French name like this
It appears that as a general rule, the primary language is returned by default (for Algeria this is Arabic), but in the cases where a separate script is used an alternative may be returned. For an English language request, the road names in Algeria are returned in French (i.e. the standard 26 letter Roman Alphabet) rather than Arabic script.
The Map Tiler can display bilingual maps as shown below:
lg=FRE&lg2=DUT Map of Brussels at zoom 10
However the roads are only displayed in the primary language
lg=FRE&lg2=DUT Map of Brussels at zoom 17
Presumably this is due to the optimization of the label placements.
For languages with different scripts, both labels are shown
lg=ARA&lg2=FRE Map of Oran at zoom 11
This includes the roads displayed in the secondary language at high zoom
lg=ARA&lg2=FRE Map of Oran at zoom 17
The list of languages available to the lg and lg2 parameters can be found in the Map Tile API Reference. Examples of monolingual and bilingual maps tile can be found in the API Explorer
The lg and lg2 can also be passed to the Maps API For JavaScript as shown:
var mapTileService = platform.getMapTileService({
type: 'base'
}),
bilingualMapLayer = mapTileService.createTileLayer(
'maptile',
'normal.day',
256,
'png8',
{lg: 'ARA', lg2: 'FRE'}
);
map.setBaseLayer(bilingualMapLayer);
Where map is an instance of an H.Map and platform is the
H.service.Platform stub.

Correct address format to get the most accurate results from google GeoCoding API

Is there any standard format to supply the address string to Google GeoCoding API to get the most accurate results on map.
For Eg. following query not giving correct result.
http://maps.googleapis.com/maps/api/geocode/xml?address=bloom,Bloomfield,CT,06002,USA&sensor=false
Thanks
Mandeep
I believe the suggested format is:
House Number, Street Direction, Street Name, Street Suffix, City, State, Zip, Country
The results get less specific the less information you can supply, obviously.
In your sample, the geocoder is searching for a street named 'bloom', of which there are similar matches in OH instead of CT. Removing 'bloom' from the query and then searching returns Bloomfield, CT.
Definition of Google address search:
address - The street address that you want to geocode, in the format used by the national postal service of the country concerned. Additional address elements such as business names and unit, suite or floor numbers should be avoided.
https://developers.google.com/maps/documentation/geocoding/#geocoding
How should I format my geocoder queries to maximise the number of successful requests?
The geocoder is designed to map street addresses to geographical coordinates. We therefore recommend that you format geocoder requests in accordance with the following guidelines to maximise the likelihood of a successful query:
Specify addresses in accordance with the format used by the national postal service of the country concerned.
Do not specify additional address elements such as business names, unit numbers, floor numbers, or suite numbers that are not included in the address as defined by the postal service of the country concerned.
Use the street number of a premise in preference to the building name where possible.
Use street number addressing in preference to specifying cross streets where possible.
Do not provide 'hints' such as nearby landmarks.
https://developers.google.com/maps/faq#geocoder_queryformat
I found the answer incomplete and it lacked a source.
Look here: https://developers.google.com/places/documentation/autocomplete#place_autocomplete_responses
The maps autocompletion API from google returns a much simpler format: "Street address, City, Country"
Now you can use a string like that to search for an address and it should lead to one exact result.
In addition if you use the autocompletion API you will get a unique identifier too which can be used for further detail requests.
The format of the street address greatly depends on the location where you actually are.
In the US "House number, street direction, street name, street suffix" might make sense, in most of Europe it will not lead to successful query.
Addresses in most of EU are different (often "Streetname number suffix") like "Kumpelstraat 25A","Psolevcu 331/26b") and I guess we'd be surprised if we look at some eastern countries.
So if you bind your code to a single area (US, most of EU) you might be good hardcoding the format.
If you want to have a more flexible system you either need to find out propper formating for your target audience or query one of googles APIs to automatically get a proper string.
The one I linked is very good but requires an API key with a free request limit per day.
I stumbled upon this question and found a solution that worked for me:
I think the answer can be found by using component filtering, look at:
https://developers.google.com/maps/documentation/geocoding/#ComponentFiltering
An example in Javascript:
var request = require('request');
var url = "https://maps.googleapis.com/maps/api/geocode/json?" +
"address=Herengracht 180" +
"&components=postal_code:1016 BR|country:NL" +
"&sensor=false";
request(url, function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
}
else {
console.log('error', error);
}
});
No need to avoid apartment units. This works:
https://maps.googleapis.com/maps/api/geocode/xml?address=14202+N+42nd+St+Unit+301+33613
"Apt", "Room", and "Suite" work as well
They all return 301 as subpremise and are shown in "formatted_address" as "#301."
Paul sends...
I found that official country codes like "US", "DE", "FR" do not work well. Replacing them with the full country name gives much better results for me.
I did not find a source where that is stated.

Resources