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.
Related
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
I have a site implementing "Google Map API v3" to create a map with pushpins of the yoga studios in our DB. Unfortunately, the locations are all in Japan. We have the addresses in English and Japanese, however, Google Maps is not so flexible with Japanese addresses in English and our DB of addresses is not the cleanest, so sometimes addresses do not display properly. Our addresses in Japanese characters (kanji) are probably fine and I would like to use them, so here is the problem...
When using addresses in kanji with the Google Map API, the maps shows completely wrong locations. But when I input the same address manually in Google Maps, it accurately delivers.
Is there a language setting or something?
Thank you.
Update and another question...
I figured out how to get the correct locations onto the map by editing the 'GoogleMapAPIv3.class.php' file here:
public function geocoding($address)
{
$encodeAddress = urlencode($this->withoutSpecialChars($address));
$url = "http://maps.google.com/maps/geo?q=".$encodeAddress."&output=csv";
...etc...
Changed the '$url...' line to:
$url = "http://maps.google.com/maps/geo?q='".$address."'&output=csv";
To make the function just use the inputted address as is. My question is, will that cause any problems with anything else?
Keep in mind this map function is only used to map locations residing in our DB, so the addresses are only limited to what is there. i.e. no random user input.
Thanks again.
change $url = "http://maps.google.com/maps/ to $url = "https://google.co.jp/maps/ and if you want you can add language=ja at the end so that the language is japanese for example:
https://google.co.jp/maps/api/js?language=ja
https://developers.google.com/maps/documentation/javascript/examples/map-language
and https://google.co.jp/maps/ is google maps on Japan
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.
I'm using http://gmap.nurtext.de/documentation.html library to display the map for my address field (mysql table)
How I can get the latitude and longitude for each address, for example:
I have this address: 'McLester road'
Note:
my visitor (user) who added the address (into Mysql table)
Enter the desired address into Google Maps.
Now, enter this into the address bar:
javascript:void(prompt('',gApplication.getMap().getCenter()))
This will return the longitude and latitude for you. Simply copy and paste these numbers into your code.
EDIT
Since this question is still getting some attention I'd like to say that nowadays most browsers will search for the text you put into the address bar, so instead it may be better to open up your browser's console and just enter a portion of the above code:
prompt('',gApplication.getMap().getCenter())
Also, if you just want the just the javascript object returned, just call:
gApplication.getMap().getCenter()
That way, you can do things programatically as well.
Google's geocoding sevice can convert address to coordinates.
There is a javascript api, but geocoding is available as a webservice too.