I need to request in google geocode api to get geocodes. I've city, district, number and state and I'm requesting
https://maps.googleapis.com/maps/api/geocode/json?address={street}, {number} - {district}, {city } - {state} ... `
I'm sending a city, but google is returning to another city.
is there a way to force-find geocode in the city that I'm sending?
Or force parameters at query, like:
https://maps.googleapis.com/maps/api/geocode/json?city={city}&state={state}
It doesn't look like Google Maps supports passing in structured address data, only address strings. Consider taking a look at Azure Maps, it has a service where you can pass in each part of your address as separate parameters. This will likely be more inline with what you are looking for. Here is the service documentation: https://learn.microsoft.com/en-us/rest/api/maps/search/getsearchaddressstructured
Here are some related resources:
https://azure.com/maps
https://learn.microsoft.com/en-us/azure/azure-maps/
https://azuremapscodesamples.azurewebsites.net/index.html
Related
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.
I am trying to geocode addresses on Google Maps using the google_geocode function from the package googleway in R. I am using a key obtained from Google that allows me to go over the 2500/day limit (and being charged for that). I have different types of problems, mainly due to the way the addresses I use are written, but there is one issue that I would like to ask here: how is it possible that I sometimes get no results querying with googe_geocode, but if I type the same address string on http://www.google.com/maps/ it does return a result?
My example:
address="AVENDAÑO, 30-32 VITORIA-GASTEIZ 01008, ES"
# the address I want to geocode. Its format is "street, number, city postcode, country" in a single string.
google_geocode(address=address,key=mykey) # I write the right key as mykey.
# I get no results:
$results
list()
$status
[1] "ZERO_RESULTS"
But, if search for exactly the same address string in Google Maps, I get the right location (showing that this is Abendaño Kalea in Vitoria, Spain):
https://www.google.com/maps/place/Abenda%C3%B1o+Kalea,+30,+01008+Vitoria-Gasteiz,+Araba/#42.8451894,-2.6855022,17z/data=!3m1!4b1!4m5!3m4!1s0xd4fc213d775d83d:0xc2a5f2ffa8721c2a!8m2!3d42.8451855!4d-2.6833135
Can anyone explain what may be going on? Maybe some staff from Google Maps or Google Geocoding API may help?
Thanks a lot,
Note that Google knows this street as 'ABENDAÑO, 30-32 VITORIA-GASTEIZ 01008, ES', so the B and V letters are important. I know that in Spanish language this is the same sound, but probably Google expects exact match.
According to the documentation:
Specify addresses in accordance with the format used by the national postal service of the country concerned.
source: https://developers.google.com/maps/faq#geocoder_queryformat
On the Correos.es I can see that the official street name is ABENDAÑO as shown in the following screenshot
So just use the following request to get results:
https://maps.googleapis.com/maps/api/geocode/json?address=ABENDA%C3%91O%2C%2030-32%20VITORIA-GASTEIZ%2001008%2C%20ES&key=YOUR_API_KEY
Or the same thing in geocoder tool:
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3DABENDA%25D1O%252C%252030-32%2520VITORIA-GASTEIZ%252001008%252C%2520ES
I hope this helps!
I think it is likely that is due to encoding issues. I have had this happen when trying to geolocate addresses with "Ñ". Doing this worked for me:
string <- "AVENDAÑO, 30-32 VITORIA-GASTEIZ 01008, ES"
Encoding(string) <- "UTF-8"
google_geocode(string, key = key)
Since google changed their pricing scheme now you need to have an API key.
I am trying to create a Store Locator with the Google API, very similar to the one in the Google examples here:
http://storelocator.googlecode.com/git/examples/panel.html
However I've hit a wall trying to get the Store Locator API to get the user's position through Geolocation, so when I click on Get Direction in the infowindow I get directions to the user position; instead of having to type my address in the: Where are you? Panel box.
In the documentation what I have seen is that geolocation is a boolean in the View Option that is set to True by default. But this does not solve my problem.
Does anyone have any idea on how to do this?
seems that the googlecode page you said is no longer exist. So I can't give any further insight about what you want to make.
However, by your description, Luckily I made similar site few months ago. It is on Grocery Store Near Me .
The concept of Geolocation is an HTML5 (actually W3C) Geolocation API which is now already embed in most modern browser. It is an API which you can obtain user's location (latitude, longitude, altitude, and accuracy).
you can call it with simply
navigator.geolocation.getCurrentPosition(success, error, geo_options);
Success and error is a callback function in which you can define.
In my case, the function looks like these
function success(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
// use the lat and long to call function to fetch an API through AJAX
fetchStoreData(latitude, longitude);
}
In the Store Locator schema (like mine in Grocery Store Near Me), Geolocation is used to obtains user lat and long. The lat and long, then send to server via AJAX to get data about nearby store location.
The server serve an API in which accept lat and long as parameter, then fetch the store data (either using database, or other external API like foursquare), then you can display it either on list, or on a maps.
I am writing an app to use GPS coordinates obtained by the cell phone itself to retrieve the building name of that location.
For example, if I use this http URL to request with Google Place API:
https://maps.googleapis.com/maps/api/place/search/json?location=40.805112,-73.960349&radius=10&sensor=false&key="YourKey"
I can only get the street name of this coordinate through this.
But if I type "40.805112,-73.960349" in maps.google.com. I can get the exact building name. SO I was wondering how can I use Google Map API to obtain the building name I want.
Thank you very much about this!!!
The first result in the request you provided contains "name" : "Church of Notre Dame", isn't this what you are looking for?
A better request if you are only interested in the place name at this location would be to use the rankby=distance parameter instead or radius and to filter by type=establishment:
https://maps.googleapis.com/maps/api/place/search/json?location=40.805112,-73.960349&rankby=distance&types=establishment&sensor=false&key=YOUR_API_KEY
This would return the closest place at the given location.
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.